I have a projection function that I pass to IQueryable<>.Select()
method:
private static Expression<Func<VendorPrice, PriceItem>> GetPriceSelector(){
return e => new PriceItem {
Id = e.Id,
Price = Math.Round(e.Price, 4)
};
}
Everything works just fine but I want to parameterize it like that:
private static Expression<Func<VendorPrice, PriceItem>> GetPriceSelector(Func<VendorPrice, decimal> formula){
return e => new PriceItem {
Id = e.Id,
Price = formula(e)
};
}
so that I can call it like
prices.Select(GetPriceSelector(e => Math.Round(e.Price, 4)))
Unfortunately, EF complains about it:
The LINQ expression node type 'Invoke' is not supported in LINQ to Entities
How to rewrite the code to make EF happy?