Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Petr Snobelt 923 posts 1535 karma points
    Apr 19, 2012 @ 21:41
    Petr Snobelt
    0

    Can only use aggregate methods on properties which are numeric

    Hi,

    I have price stored in textbox property. I can't use numeric, because I need decimal places. When I try to use sum method on this property error "Can only use aggregate methods on properties which are numeric" occured.

    I really need sum on this property, what is the best solution for this? I hope there is better way then foreach.

     

    Thanks 

  • Douglas Ludlow 210 posts 366 karma points
    Apr 20, 2012 @ 17:17
    Douglas Ludlow
    0

    Could you show a code sample of what you are doing exactly?

  • Petr Snobelt 923 posts 1535 karma points
    Apr 20, 2012 @ 19:42
    Petr Snobelt
    0

    Samples - don't work: 

    var notworking_totalPrice = Model.Children.Sum("priceTotal"); //don't work

    priceTotal is textstring property (because I need decimal places)

    This works, but it's boring:

    decimal totalPrice = 0;
    foreach (var item in Model.Children)
    {
        totalPrice += decimal.Parse(item.priceTotal);        
    }

    Petr

Please Sign in or register to post replies

Write your reply to:

Draft