How To Get The Table -1 Records Based On Table – 2 Id Using join
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
public List<LineItem> GetAllLineItems(int? enquiryId = 0)// { // context.Configuration.LazyLoadingEnabled = false; IEnumerable<LineItem> qry = context.LineItems.ToList(); var q = (from li in qry join e in context.Enquiries on li.FKEnquiryId equals e.PKEnquiryId join c in context.Customers on e.FKCustomerId equals c.PKCustomerId select new { CustomerName = c.CustomerName, PRNumber = e.PRNo, QuotationNumber = e.QuotationNumber, Itemcode = li.ItemCode, EnquiryQuantity=li.EnquiryQuantity, QuotedPrice = li.QuotedPrice, DetailedDescription = li.DetailedDescription, DateofEnquiry = e.DateCreated, }).AsEnumerable().Select(x=> new LineItem { CustomerName=x.CustomerName, PRNumber=x.PRNumber, QuotationNumber=x.QuotationNumber, ItemCode =x.Itemcode, EnquiryQuantity=x.EnquiryQuantity, QuotedPrice =x.QuotedPrice, DetailedDescription=x.DetailedDescription, DateCreated=x.DateofEnquiry }).ToList(); if(enquiryId!=0) { q = qry.Where(x => x.FKEnquiryId == enquiryId).ToList(); } return q.ToList(); } |
Please follow and like us: