I have a Func<ProductItemVendor, bool>
stored in CompareProductItemVendorIds
. I would like to use that expression in a LINQ query.
It appears the following is legal:
var results =
Repository.Query<ProductItemVendor>().Where(CompareProductItemVendorIds);
However, the following is not legal:
var results = from v in Repository.Query<ProductItemVendor>()
where CompareProductItemVendorIds(v)
select v;
This code produces an error:
The LINQ expression node type 'Invoke' is not supported in LINQ to Entities.
Questions:
Why are these statements so different that my
Func<>
is legal in one but not the other? I thought they both basically did the same thing.How can I make this work? Do I have to explicity create my
Func<>
as anExpression<Func<>>
instead?
Please see my related question at Using Expression<Func<>> in a LINQ Query.
CompareProductItemVendorIds
in the 1st example the same asCompareProductItemVendorIds(v)
in the second? – AutoFunc<>
is stored, which I described in the first paragraph. – Scuttlebutt