I have IQueryablewith NHibernate, and I would like to have a linq query to summarize a specific column, but when my condition in the method Wheregives me an empty result, I do not want to get an exception, but I would not want to hit the request to get all the records, and after summing it from memory I would like something like coalesesql command, for a sample:
var query = MyQueryable()
.Where(x => x.IsDone)
.Select(x => x.Value)
.Sum();
I need to do something like this:
var query = MyQueryable()
.Where(x => x.IsDone)
.Select(x => x.Value)
.ToList()
.Sum();
Is there any way?
Thank.
source
share