2011-07-26 3 views
2

행운을 비면서 EntityReference로 데이터를 필터링하려고합니다. 나는 또한 SubCategory.Name를 사용하여 시도웹 서비스에서 반환 된 Dynamics CRM 2011 데이터 필터링

/// <summary> 
     /// Gets the categories. 
     /// </summary> 
     /// <returns></returns> 
     public IEnumerable<category> GetCategoriesExcludingSomething() 
     { 
      IEnumerable<category> data = CrmClient.categorySet.OrderBy(x => x.SubCategory).ThenBy(x => x.itf_name); 

      return data.Where(x => x.SubCategory.ToString() == "SomethingToExclude"); 
     } 

하지만 다음은

The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.

가 CRMService를 호출 내 방법 : where 절없이 내가 다음과 같은 오류를 얻을 수 where 절에 잘 실행 같은 오류가 발생합니다. 초기 바인딩이나 그 라인을 따라 뭔가를 사용한다는 사실과 관련이 있다고 생각하지만 디버깅 할 때 유용한 정보를 얻을 수 없었습니다.

어떤 조언이나 도움이 좋을 것,이 쉬워야한다 :/

답변

2

이 문서에 따르면 : 당신은 무엇을 할 수 있는지 http://technet.microsoft.com/en-us/library/gg328328.aspx

The LINQ query provider supports a subset of the LINQ operators. Not all conditions that can be expressed in LINQ are supported.

orderBy supports ordering by entity attributes, such as Contact.FullName.

사용 먼저 where 절을 사용하는 것입니다 ToList() 메소드. 이 후, 모든 일반적인 Linq 쿼리를 사용할 수있는 데이터 모음을 갖게됩니다.

또한 EntityReference를 OrderBy하려고 시도하는 것은 좋은 방법이 아닙니다. 이 같은 주문하려고한다 :

OrderBy(x => x.SubCategory.Id) 

where: The left side of the clause must be an attribute name and the right side of the clause must be a value. You cannot set the left side to a constant. Both the sides of the clause cannot be constants. Supports the String functions Contains, StartsWith, EndsWith, and Equals

은 당신이 여기에서 할 수있는 것은 ID로 또는 이름으로 필터링 값 (즉,이 경우 당신이하는 EntityReference에서해야하는 유일한 관련 정보의) 중 하나입니다 .

Where(x => x.SubCategory.Name == "CategoryNameToExclude"); 
관련 문제