Я знаю, что в настоящее время компилятор не нравится этому утверждению. Получение ошибкиStumped on Entity Framework & Lambda Expressions
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
мое заявление я передаю моему Repository класса
var qry = repositoryClass.Find(c => c.Categories.Where(d => d.CategoryParentID == typeID));
Repository Class Найти метод
public IEnumerable<SomeModels> Find(Func<SomeModels, bool> exp)
{
return (from col in _db.SomeModels where exp select col);
}
Я не уверен, что это приемлемый способ сделать это, поэтому, пожалуйста, поделитесь лучшими практиками. Я еще не самый лучший в Лямбде. – OneSmartGuy
Re comment - я не уверен на 100%, что модель выглядит, так трудно следовать ... но похоже, что вы можете захотеть c => c.Categories.Any (d => ...) –