Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将sql查询转换为lambda表达式_C#_Sql_Linq - Fatal编程技术网

C# 将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

这是我的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.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表达式的教程