2016-11-24 7 views
1

です。LINQフィルタコレクションは、私はクラスの下に定義されているサブコレクション

今、私は(AssignmentDictionaryDTOChildItemから)テキストフィールドでの私のモデルをフィルタリングする

model = model.Where(x => x.ChildItems.SelectMany(y => y.text.ToLower().Contains(q), z => z)); 

が、それはコンパイルされません - 私は上記のクエリではzがあることを、知っている例外

The type arguments for method 'System.Linq.Enumerable.SelectMany<TSource,TCollection,TResult>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,System.Collections.Generic.IEnumerable<TCollection>>, System.Func<TSource,TCollection,TResult>)' cannot be inferred from the usage. Try specifying the type arguments explicitly. 

下に投げますAssignmentDictionaryDTOChildItem型のモデルであり、私のモデルはAssignmentDictionaryDTO型のリストなので適合しません。 上記のフィルタリングを実現するためにクエリを修正するにはどうすればよいですか?

答えて

1

何について:

model = model.Where(x => x.ChildItems.All(y => y.text.ToLower().Contains(q))).ToList(); 
//or Any instead of All 
関連する問題