An exception occurs when the following IQueryable
is enumerated:
from record in dataContext.SomeTable
select Convert.ToDecimal(record.nullableDecimalColumn);
The error is an InvalidOperationException
:
The null value cannot be assigned to a member with type decimal which is a non-nullable value type
The documentation for Convert.ToDecimal
says that it converts null
to 0
, so it looks like it should work correctly.
Best Answer
If you wrote Query like this
Replace with
Hope this will help you