Description

Linq query fails when trying to sum a decimal: session.Query<Payment>().Where(x => x.Customer.Id == 4).Sum(x => x.Amount);

.NET version 4, SQL server 2008

Environment

None

Attachments

1

Activity

Show:

Oskar Berggren March 6, 2013 at 9:09 AM

The question is not how to implement it, but if it's a good idea or not. I closed the bug with the reasoning that we should follow the semantics of L2SQL and L2EF. Now I think there are rumors that the behavior on L2EF might be changed to return 0 when there are no matching rows. If that's true maybe we should reopen.

Really, "var sum = myQuery.Sum(x => (int?)x.Prop) ?? 0" is a decent workaround for now.

Anish Patel March 6, 2013 at 8:52 AM

how about the option to use the ?? coalesce, which could be converted to ISNULL() is SQL?

Oskar Berggren March 5, 2013 at 6:19 PM

Please read at least my comments from october and november 2012 above.

Anish Patel March 5, 2013 at 5:30 PM

why won't this be fixed?

Oskar Berggren November 11, 2012 at 9:39 PM

Due to now clean and easy way to solve this robustly, the current behavior, which matches L2SQL and L2EF will remain for now. Closing as won't fix.

Won't Fix
Pinned fields
Click on the next to a field label to start pinning.
Details

Assignee

Unassigned

Reporter

John Duckworth

Labels

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created April 10, 2012 at 11:34 AM
Updated March 6, 2013 at 9:09 AM
Resolved November 11, 2012 at 9:39 PM
Who's Looking?
Loading...