Can I configure a strongly typed data set to use nullable values?
Posted
by Dan Tao
on Stack Overflow
See other posts from Stack Overflow
or by Dan Tao
Published on 2010-05-03T14:32:48Z
Indexed on
2010/05/03
14:38 UTC
Read the original article
Hit count: 250
If I have a strongly typed data table with a column for values of type Int32
, and this column allows nulls, then I'll get an exception if I do this for a row where the value is null:
int value = row.CustomValue;
Instead I need to do this:
if (!row.IsCustomValueNull()) {
int value = row.CustomValue;
// do something with this value
}
Ideally I would like to be able to do this:
int? value = row.CustomValue;
Of course I could always write my own method, something like GetCustomValueOrNull
; but it'd be preferable if the property auto-generated for the column itself simply returned a nullable. Is this possible?
© Stack Overflow or respective owner