2017-03-10 3 views
0

ラムダ式ツリー述語を初めて使用しています。私は次のコードを使用してwhere条件でカスタム式ツリーメソッドを使用しようとしています。しかし、エラーを得る。私は取得していますC#linqクエリ構文でラムダ式ツリーを使用する方法

from c in context.customers 
join d in context.departments on c.deptid equals d.deptid 
where (CheckForCriteria(new string{}{....})) 

private Expression<Func<Customer,bool>> CheckForCriteria(IEnumerable<string> keywords) 
{ 
    var keywordGroups = keywords.Select(k => k.Split(' ')).ToArray(); 

    return customer => keywordGroups. 
          All(keywordGroup => keywordGroup. 
           All(keyword => customer.Name.Contains(keyword)))); 
} 

エラーは次のとおりです。

​​

誰も私が私が間違ってやっていることを識別するために助けることができますか? ありがとう

答えて

0

正直言って、ここで何をやっているのか分かりません。しかし、 "where"ステートメントでは、いくつかのオペレータアクションが必要です。だからここでは "どこ"の代わりに "選択"を使ってみることができます。

例:

var result = from c in context.customers 
      join d in context.departments on c.deptid equals d.deptid 
      select CheckForCriteria(new [] { "..." }); 

例(メソッド・チェーン):

var result = (from c in context.customers 
       join d in context.departments on c.deptid equals d.deptid 
       select CheckForCriteria(new string[] { "..." })).Name).ToList(); 

var result = context.customers.Join(context.departments, c => c.deptid, d => d.deptid, (c, d) => new { c, d }) 
           .Select(x => CheckForCriteria(new [] { "..." })); 

あなたはこれを試すことができますフィルタ名のリストを取得するには

関連する問題