New Posts New Posts RSS Feed: question regarding to the anonymous type
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

question regarding to the anonymous type

 Post Reply Post Reply
Author
monkeyking View Drop Down
Groupie
Groupie
Avatar

Joined: 04-Mar-2009
Location: brisbane
Posts: 68
Post Options Post Options   Quote monkeyking Quote  Post ReplyReply Direct Link To This Post Topic: question regarding to the anonymous type
    Posted: 27-Sep-2009 at 9:49pm
the red squared section can crash the program when it's a null, what i want to do is converting the value (of debtorSales, cashSales or grossTotal) into 0 when it's a null, but in anonymous type, I don't think i can put any logic statment inside, such as if statement. so is there any way to resolve it?

Regards,
John


Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 28-Sep-2009 at 3:16pm
You can check for nulls when summing -
 
...   .Sum(o => o.SALES_PRICE == null ? 0 : o.SALES_PRICE)
 
 
Back to Top
monkeyking View Drop Down
Groupie
Groupie
Avatar

Joined: 04-Mar-2009
Location: brisbane
Posts: 68
Post Options Post Options   Quote monkeyking Quote  Post ReplyReply Direct Link To This Post Posted: 28-Sep-2009 at 5:56pm
Thanks, I think your way should work logically, but unfortunately the same error occurs.

all other properties doesn't have any problems, the problem only occur on 'cashSales' (even not in debtorSales), i'm sure for that.



Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 29-Sep-2009 at 7:51pm
Oh sorry.  This has already been fixed in current bits (for a separate problem) and that's what I tested against when answering previously.  So that's the good news - it will be fixed in the mid-October release.  The bad news, I don't have a workaround for you to use right now.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down