JetEntityFrameworkProvider icon indicating copy to clipboard operation
JetEntityFrameworkProvider copied to clipboard

Cast issue for type Decimal

Open hubert17 opened this issue 7 years ago • 4 comments

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

hubert17 avatar Jan 11 '18 16:01 hubert17

Could you please provide the model? I can't reproduce the issue (see Model74_Decimal_Jet)

bubibubi avatar Jan 13 '18 09:01 bubibubi

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

hubert17 avatar Jan 29 '18 14:01 hubert17

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.

bubibubi avatar Jan 29 '18 17:01 bubibubi

Eggzacklee. I'm looking forward for the best fix of this issue. Thanks!

hubert17 avatar Feb 03 '18 15:02 hubert17