I\'ve got a DateTime? that I\'m trying to insert into a field using a DbParameter. I\'m creating the parameter like so:
DateTime?
DbParameter
If you are using SQLServer, the System.Data.SqlTypes namespace contains some utility classes that avoid the annoying type casting. For example instead of this:
System.Data.SqlTypes
var val = (object) "abc" ?? DBNull.Value;
you can write this:
var val = "abc" ?? SqlString.Null;