JetEntityFrameworkProvider
JetEntityFrameworkProvider copied to clipboard
Cast issue for type Decimal
I am raising this issue. I encountered this issue when using type Decimal. Non-issue for type Double.
storeDb.Carts.Where(x => x.CartId == ShoppingCartId).Sum(t => t.Quantity * t.Item.UnitPrice);
InvalidOperationException: invalid PrimitiveTypeKind for cast(): cannot handle type Decimal with Jet
Could you please provide the model? I can't reproduce the issue (see Model74_Decimal_Jet)
Hi Bubi! I have fixed the issue by .ToList() first before .Sum()
Check this out.
https://github.com/hubert17/MyAspNetMvcApp/blob/e0fbf271cab37c6d5f70ddfde299b608c677d16e/MyAspNetMvcApp/Areas/OrderFramework/ViewModels/ShoppingCart.cs#L137
I'll check it out.
About ToList consider that you materialize the list of records and then you compute the sum (instead of materializing the sum) so it's bad for large amount of data.
Eggzacklee. I'm looking forward for the best fix of this issue. Thanks!