My view model has a date property with a null value, such as ...
[DataType(DataType.Date)]
public DateTime? SanctionExpires { get; set; }
But when I try to use a zero coalescing operator like ...
var test = model.SanctionExpires.Value.ToUniversalTime() ?? model.SanctionExpires;
I get the following error ...
Operator'??' cannot be applied to operands of type 'datetime' and 'DateTime'
I thought this should work, because I set the date property to nullable and this post assumes it should work too. What am I doing wrong?
UPDATE
, null-coaslescing Dapper, DateTime . NULL datetime. , , , ...
p.Add("@SanctionExpires", model.SanctionExpires.Value.ToUniversalTime() ?? model.SanctionExpires);
, UTC, SQL Azure, UTC , 11 ( ), . sql .
, , . ...
if (model.SanctionExpires == null)
p.Add("@SanctionExpires", model.SanctionExpires);
else
p.Add("@SanctionExpires", model.SanctionExpires.Value.ToUniversalTime());