Jaima Joseph

Jaima Joseph

  • NA
  • 94
  • 107.3k

how to write query in MVC controller joining 3 tables?

Jan 10 2014 1:12 AM

Hi,Can anybody tell me how to write query to fetch one column value from a table comparing other two column values in that table with other two tables in an MVC Controller?

In my MVC view I need to show 5 column values from one table say POCList and the sixth value(localstock) to be displayed should be fetched from second table say StockMaster which is having matching values in 3rd table Inventorymaster.

My query should be like "select  Qty from StockMaster where StockMaster.SKU==POCList.SKU && (StockMaster.SKU==InventoryMaster.SKU &&StockMaster.LocationId==InventoryMaster.LocationID"
 
I don't know how to write it as a MVC query....Also please tell me how to show this value in view along with other 5 values from POCList table...
 
Righ now my view is showing all the 5 column values fro POCList properly in my view using the below code 
 

public ActionResult GeneratePOC()




{



var generatepoc = db.POCLists.Include(p => p.EmployeeMaster).Include(p => p.POCMaster).Include(p => p.QuoteMaster).Include(p=>p.SKUMaster);






return View(generatepoc.ToList());




}


Any help will be appreciated..Its urget...Thanks in advance.


 

Answers (3)