0

enter image description hereHow to use leftouter join in entity framework query

I have two table one is item and other is stock available I want to get all items and also get its quantity from stock available table which depend upon the particular department

1 Answer 1

2

For example LINQ Query

var query = (from p in dc.GetTable<Person>()
join pa in dc.GetTable<PersonAddress>() on p.Id equals pa.PersonId into tempAddresses
from addresses in tempAddresses.DefaultIfEmpty()
select new { p.FirstName, p.LastName, addresses.State });

SQL Translation

SELECT [t0].[FirstName], [t0].[LastName], [t1].[State] AS [State]
 FROM [dbo].[Person] AS [t0]
 LEFT OUTER JOIN [dbo].[PersonAddress] AS [t1] ON [t0].[Id] = [t1].[PersonID]
Sign up to request clarification or add additional context in comments.

2 Comments

please tell me the query in linq to entitity this is in linq to sql

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.