Skip to content
Advertisement

Join multiple tables and single output using Entity Framework mvc5

I am very new to linq query so I need to join multiple tables and single output using Entity Framework mvc5

Below is my 3 table structures and Table_Application is a main table

1) Table_Application

2) Table_Service

3) Table_Product

I need linq out result data in linq list base on Table_Application ID

my sql query some thing like that

I tried for single table coming but not able to join Table_Service and Table_Product

Advertisement

Answer

Take a look at the LINQ query syntax – it’s similar to SQL so can be easier to understand if you’re coming from that sort of background.

There’s a tutorial on http://www.tutorialsteacher.com/linq/linq-query-syntax which will give you a basic starting point, then you can just add in joins etc as required.

Note that the following is untested and will give you a list of IAViewModel objects, but I think you would want something similar to the following:

If you only want a single result out of it, you can leave out the .ToList() and instead use something like .FirstOrDefault()

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement