Are you getting this?
The null value cannot be assigned to a member with type System.Int64 which is a non-nullable value type.
On something like this?
var totalSize = query.Sum(x => x.Size);
This occurs because your LINQ property (in my case “Size”) is not nullable, and needs to be nullable because your
Sum() operation could potentially iterate over a list which is empty yielding your LINQ property value to be
Of course you can’t
Sum() null as we know or the universe would explode, so try this instead:
var totalSize = query.Sum(x => (long?) x.Size);
This may very well just be a LINQ to SQL thing, but I am not sure. Maybe somebody else out there in the wide world web can enlighten me!
Best of luck!