Monday, May 2, 2016

Inner Join using LINQ



Create query:


var queryOfficeInfo = from ofc in db.Offices
join llo in db.LLOs
on ofc.Office_Name equals llo.LLO_Name
select new
{
ofc.Office_ID,
llo.tp_ID,
ofc.Office_Name
};



Retrieve Query:



var result = queryOfficeInfo.Where(q => q.tp_ID.Equals(obj.LLO_ID));
//Update the FCJC Record to reflect correct office relationship


obj.Office_ID = result.Select(a => a.Office_ID).FirstOrDefault();



No comments:

Post a Comment