我知道很多問題都與此錯誤有關,但我無法找到將我的查詢轉換爲符合我的查詢的方法。我的錯誤:'LINQ to Entities does not recognize the method 'Boolean TryGetValue(Int32, System.Collections.Generic.List
1 [System.Nullable 1[System.Int32]] ByRef)' method, and this method cannot be translated into a store expression.
' 我的思想正在融化!C#LINQ to Entities不能識別該方法TryGetValue
var groupedKeyAndValueOfProjectIdAndZoneIds = groupedProjectDelegationByProjectId.ToDictionary(keySelector: x => x.ProjectId, elementSelector: x => x.ZoneIds);
...
var data = projects
.Select(p => new Project
{
Id = p.Id,
ProjectName = p.Name,
Zones = p.Zones.Where(z =>
(zoneIds.Contains(z.Id) || (groupedKeyAndValueOfProjectIdAndZoneIds.TryGetValue(p.Id, out outValue) ? outValue.Contains(z.Id) : false)))
... 鑑於groupedKeyAndValueOfProjectAndZones是Dictionary<int, List<int>>
。 請幫幫我。
你爲什麼不拿儘量讓你的問題更具可讀性?這些小東西可以幫助你更快地獲得答案。 –