4

I prefer working with DateTime.MinValue, even if I use SqlServer as backend.

Is it possible to make Entity Framework to convert from DateTime.MinValue to 1753-01-01 when saving entities and convert back to DateTime.MinValue when fetching them?

Edit: I do not want to use DateTime? (nullable value type)

2
  • 5
    You prefer DateTime.MinValue (and the SQL Server minimum datetime value) to null? Really? Commented Sep 1, 2010 at 14:51
  • 1
    Yes, Date comparsion is a tidier when comparing to MinValue than have to check for null everywhere. Same reason as why string.Empty exists. Commented Sep 23, 2010 at 13:36

1 Answer 1

2

If SQL Server 2008 is an option, you could go with using datetime2 in your database which would allow you to store DateTime.MinValue.

Sign up to request clarification or add additional context in comments.

1 Comment

Accepted the answer since no EF4 answers are avail. A datetype filter similar to IUserType in nhibernate would be preferable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.