Jaima Joseph

Jaima Joseph

  • NA
  • 94
  • 106.3k

How to fetch data from second table based on value in first?

Jan 3 2014 4:50 AM

Hi,

Please help,

How to fetch data from second table based on its id which is saved in first table in mvc?
I have two tables Quotation and Items. In quotation Item id(which is foreign key in quote table and primary key in item table) is saved  and using this id,I want to fetch its manufacturer from Items table?I want to show it in my view along with other data from Quotation table.
following is my code where I am trying this, 
 




public ActionResult CloseQuoteCycle(





{



var quotemasters = db.QuoteMasters.Include(q => q.CreditTerm).Include(q => q.EmployeeMaster).Include(q => q.SKUMaster).Include(q => q.SupplierMaster).Include(q => q.CommunicationMode);


var apprvedquote =




(



from p in quotemasters.ToList()


where (p.Approved == true)


select p




);


























































































































































                  





// return View(model);


return View(apprvedquote.ToList());




}