私は現在コンパイラがこのステートメントを好きではないことを知っています。エラーエンティティフレームワークとラムダ式に困惑しました
Cannot convert lambda expression to delegate type 'System.Func<MyData.Models.SomeModels,bool>' because some of the return types in the block are not implicitly convertible to the delegate return type
私は
var qry = repositoryClass.Find(c => c.Categories.Where(d => d.CategoryParentID == typeID));
リポジトリクラスは、あなたがExpression<...>
を必要とするEFで作業する方法
public IEnumerable<SomeModels> Find(Func<SomeModels, bool> exp)
{
return (from col in _db.SomeModels where exp select col);
}
これが受け入れる方法であるかどうかは分かりませんので、より良い方法を教えてください。私はまだラムダでは最高ではない。 – OneSmartGuy
コメントを書き直してください - 私は100%モデルがどのように見えているかは分かりません。従うのは難しいですが、c => c.Categories.Any(d => ...)のように聞こえます。 –