I need some syntactic help with a Linq statement. The overall statement is lengthy and selects against a SQL Server database over which I have no design control.
In my select new phrase I have the following column;
on_Hand_Qty1 = (from x1 in Material_Locations
where x1.Material == j.Part_Number
&& x1.Location_ID != "MSSICONSMT"
select x1.On_Hand_Qty ?? 0.0).Sum()
,
In LINQPad I get an error of: Operator '??' cannot be applied to operands of type 'double' and 'double'
I'm using the ?? because there is a possiblity that the sub query will return no records. In that case the value should be zero.
I've tried casting the value to (double) and (double?) but I still get effectively the same error. j
I do a similar sub select on a column elsewhere in the statement an it works fine;
Consignment = (from x in Material_Locations
where x.Material == j.Part_Number
&& x.Location_ID == "MSSICONSMT"
select(float?) x.On_Hand_Qty ?? 0.0 ).ToList()
What am I missing here?
Thanks!