-5

这是我想将其转换为 lambda 表达式的 sql 查询

Select P.PlaceName As UnitNumber, 
       PB.PlaceName, 
       A.Locality, 
       A.SubLocality, 
       A.Sublocality_Level_1   
from Listing L 
inner join Place P ON L.PlaceId = P.Id
Inner Join Place PB ON PB.Id = P.ParentPlaceId
Inner Join [Address] A ON A.Id = PB.AddressId
Where L.Id =9

提前致谢 。

4

1 回答 1

0

在这种情况下,查询表达式要简单得多。我不建议您使用具有多个连接的 lambda

from l in db.Listing
join p in db.Place on l.PlaceId equals p.Id
join pb in db.Place on p.ParentPlaceId equals pb.Id
join a in db.Address on pb.AddressId equals a.Id
where l.Id == 9
select new {
   UnitNumber = p.PlaceName,
   pb.PlaceName,
   a.Locality,
   a.SubLocality,
   a.Sublocality_Level_1
}

db是你的上下文

于 2013-07-14T10:45:49.153 回答