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.
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.
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Jan 9, 2014, 9:44 PM EST
It is not MVC query or MVC part. Its Entity Framework part.
It is better to use Linq to Entity.
var query = (from pl in db.POCLists
join sm in db.StockMaster on sm.SKU equals pl.SKU
join im in dm.InventoryMaster on im.SKU equals sm.SKU
where sm.LocationId == im.LocationId select new {
SomeProp1 = pl.SomeProp,
SomeProp2 = sm.SomeValue, // six value
}).ToList();
chandu komati148 reputationPosted Jul 4, 2016, 4:42 AM EDT
companydetail
chandu komati148 reputationPosted Jul 4, 2016, 4:43 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts