Handling DateTime in ListItemRepository?

Nov 6, 2008 at 10:46 AM
Edited Nov 6, 2008 at 11:58 AM
Hi,

I´m using some non required DateTime Fields in my datalists.
When adding a item to the list via the repository, I get an error if the DateTime property of the entity is not set. Invalid datetime value.
One quick solution to this was by checking if the field is of type DateTime in the ListItemRepository, if not set a I don´t add the field to the item. Then I get the "empty" result I want.

Another to use nullable datetime properties?
Any suggestions on a better, more thought through solution to this problem ?

peace.



Developer
Nov 6, 2008 at 8:26 PM
i'm not sure if a nullable datetime would work in this situation. it would be interesting to see what happens when you use a nullable datetime property to set a list item field. You could use the combination of nullable types and checking for nulls in the ListItemRepository like you're currently doing. Just make a general rule to check for nulls for each property and if null, just ignore it.