S
shapper
Hello,
On my Linq To Sql tables the properties are of type DateTime.
The problem is that sometimes instead of filling a DateTime field with
null or set them to not null and insert minimum DateTime value ... But
the C# one is different from the SQL one.
So I need to do very often the following:
DateTime user.LastLocked = SqlDateTime.MinValue;
Which does not work ... So I created a simple extenstion to convert
SqlDateTime to DateTime:
public static DateTime ToDateTime(this SqlDateTime value) {
return DateTime.Parse(value.ToString());
} // Random
Is this ok?
Maybe I should include something about MinValue?
And should I use ConvertTo instead of Parse?
Just trying to have this working in all situations.
Thanks,
Miguel
On my Linq To Sql tables the properties are of type DateTime.
The problem is that sometimes instead of filling a DateTime field with
null or set them to not null and insert minimum DateTime value ... But
the C# one is different from the SQL one.
So I need to do very often the following:
DateTime user.LastLocked = SqlDateTime.MinValue;
Which does not work ... So I created a simple extenstion to convert
SqlDateTime to DateTime:
public static DateTime ToDateTime(this SqlDateTime value) {
return DateTime.Parse(value.ToString());
} // Random
Is this ok?
Maybe I should include something about MinValue?
And should I use ConvertTo instead of Parse?
Just trying to have this working in all situations.
Thanks,
Miguel