A
A
addd2015-11-25 10:49:37
C++ / C#
addd, 2015-11-25 10:49:37

How to do a join in Entity Framework?

select dbo.A.Link,dbo.B.Image, ...
From dbo.A INNER JOIN
dbo.B ON dbo.A.Site = dbo.B.Site AND dbo.AC = dbo.BC
where(dbo.A .Link = @categ) AND (dbo.A.Site = @site) and (dbo.B.Link = @SubCateg)
how to define this query in EF?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kovalsky, 2015-11-25
@dmitryKovalskiy

Approximately like this

var temp = from t in A
                  join b in B on t.Site = b.Site AND t.C = b.C
                  where condition
                  select what you need

V
Vitaly Litvinyuk, 2015-11-25
@Dzhamal

var result = dbContext.A.Join(dbContext.B, a => new { a.Site, a.C }, b => new { b.Site, b.C }, (a, b) => new { a, b })
                        .Where(joinedObject => joinedObject.a.Link == someValue && joinedObject.a.Site == someOtherValue && joinedObject.b.Link == thirdValue )
                        .Select(joinedObject => ...)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question