2011-07-26 17 views
2

私は運がないEntityReferenceでデータをフィルタリングしようとしています。私もSubCategory.Nameを使用してみましたがWebサービスから返された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

(それはあなたがこのケースでのEntityReferenceから必要がありますのみ関連の情報です)フィルタリング値IDまたは名前であります。

Where(x => x.SubCategory.Name == "CategoryNameToExclude"); 
関連する問題