-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