-3
我有这样的内部联接查询:如何将SQL JOIN查询转换为c#LINQ to Entity?
Select Clients.ClientName,
InspectionAuthorities.Description,
COUNT(DISTINCT ObjectTypes.Description) AS NumberOfObjectTypes
From InspectionArchives
--Customer--
Inner Join Clients On InspectionArchives.CustomerID = Clients.Id
--Inspection Authority--
Inner Join InspectionAuthorityInspectionArchives On InspectionArchives.Id = InspectionAuthorityInspectionArchives.InspectionArchive_Id
Inner Join InspectionAuthorities On InspectionAuthorityInspectionArchives.InspectionAuthority_Id = InspectionAuthorities.Id
--Object Types--
Inner Join ObjectTypeInspectionArchives On InspectionArchives.Id = ObjectTypeInspectionArchives.InspectionArchive_Id
Inner Join ObjectTypes On ObjectTypeInspectionArchives.ObjectType_Id = ObjectTypes.Id
Where Clients.Id = 1 or Clients.Id = 2
Group by Clients.ClientName, InspectionAuthorities.Description;
我新来的LINQ世界,需要上面的SQL查询转换为C#LINQ到实体。
任何想法如何实现它?
首先,您至少应该展示一个尝试自己转换它。第二次阅读[this](https://coding.abel.nu/2012/06/dont-use-linqs-join-navigate/)并学习如何使用EF为您创建的导航属性。 – juharr