Possible Duplicate:
LINQ to Entities does not recognize the method
I use Entity Framework 4.3
I write extension method:
public static IQueryable<TSource> Active<TSource>(this IQueryable<TSource> source) where TSource : class, IStatusable
{
return source.Where(s => s.Status == (int)StatusEnum.Enabled);
}
This works good:
var cat=Context.Categories.Active().ToList()
But i need use this extension method in Select. Look simplified query:
return Context.Categories
.Select(c => new { Children=c.Children.AsQueryable().Active()})
.ToList()
(Children - collection of child categories) When query execution I get a error message:
LINQ to Entities does not recognize the method 'System.Linq.IQueryable`1[Portal.FrontOffice.Model.Category] Active[Category](System.Linq.IQueryable`1[Portal.FrontOffice.Model.Category])' method, and this method cannot be translated into a store expression.
Why does not work? How to write correctly?