The following code:
model.Items = dbQuery.Select(c => new Item {
Total = c.Items.Count((Func<Item, bool>)(t => t.Amount.HasValue))
}).ToArray();
Throws the following exception:
Internal .NET Framework Data Provider error 1025.
However the exact code minus the cast works:
model.Items = dbQuery.Select(c => new Item {
Total = c.Items.Count(t => t.Amount.HasValue)
}).ToArray();
Note: dbQuery
is just an EF ObjectQuery
.
The expected type for Count()
is Func<Item, bool>
, and it's even verified by ReSharper that they're the same type by the fact that it grays the cast out, suggesting that it's not needed and they're functionally equivalent.
However, the exception proves that they are not, in fact, functionally equivalent.
Also, I did see this related question/answer, but Count()
(in this case, anyway) will not accept an Expression<Func<Item bool>>
, so that doesn't work for me.