Func parameter in LINQ expression
i have problem with Func delegate in LINQ expression. This is the
problmatic part of the method:
public static ActionResult XXX<T>(IRepository<T> repository,
Func<T, int> keyExtractor, int id = 0)
{
if (id == 0) return ...
T item = repository.Items.Where(x => keyExtractor(x) == id).
FirstOrDefault();
if (item == null) return ...
try {
repository.DeleteItem(item);
return ...
} catch (Exception e) {
return ...
}
}
But when i run the method, i get error like type of node is not in LINQ
entities supported. I tried also version with predikate but i had no luck
at all.
Any ideas how to fix it?
No comments:
Post a Comment