Question

How can I convert the following SQL select statement to Linq?

SELECT u.Name FROM User u AS DDC
INNER JOIN Country c ON c.UserId = u.UserId
INNER JOIN (
     SELECT AddressId,
            Address, 
            PC, 
        FROM AddressTbl a
    WHERE a.CountryId = 1
) AS Addresses ON Addresses.AddressId= u.AddressId

WHERE 

u.UserIs = @UserId AND
Addresses.AddressId= @AddressId

Any good reading references?

Était-ce utile?

La solution

from u in Users join 
     c in Country on  c.UserId equals u.UserId
     join a in Address on a.AddressId equals u.AddressId     
where a.CountryId == 1
select u.Name

Autres conseils

You can try this out http://www.sqltolinq.com/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top