C# 将sql查询转换为lambda表达式
这是我的sql查询,我想将其转换为lambda表达式C# 将sql查询转换为lambda表达式,c#,sql,linq,C#,Sql,Linq,这是我的sql查询,我想将其转换为lambda表达式 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.Par
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
提前谢谢 在这种情况下,查询表达式要简单得多。我不建议您将lambdas与许多联接一起使用
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
是您的上下文如果不知道对象的属性等,如何将其转换为lambda表达式?至少发布你的类结构,告诉我们你尝试了什么,以及你在这样做时面临的错误。如果你需要一个关于搜索谷歌的Lamda表达式的教程