if the one that is assigned as DateTime and the one that is assigned is DateTime? , you can use
int.RSV = pid.RSVDate.GetValueOrDefault();
This supports overloading, which allows you to specify a default value if the default value for DateTime not ideal.
If pid.RSVDate is null, I don't like to assign inv.RSV to anything, case it will be null.
int.RSV will not be null, as you said, DateTime , not a type with a null value. If it is never assigned by you, it will have a default value for this type, which is equal to DateTime.MinValue , or January 1, 0001.
inv.RSV was zero to begin with. How can I say do not update it, there is no value for pid.RSVDate
Again, this simply cannot be, given your description of the property. However, if you don't want to update inv.RSV , if pid.RSVDate is null (and you just mix your words), then you just write an if check around the destination.
if (pid.RSVDate != null) { inv.RSV = pid.RSVDate.Value; }
source share