Given a table Element with a DateTime field birthday (not null), in Entity framework 4 I am allowed to do:
Dim mylist = (From el in Element Select el).ToList()
.Select(function(el) new with {
.bday = el.birthday.toString("dd/MM/yy")
}
I am now required to change birthday to be nullable, therefore I change the table in SQL server and then update my ModelDB in Visual studio. The result is that the line:
.bday = el.birthday.toString("dd/MM/yy")
raises an exception as "Invalid cast from integer to string "dd/mm/yy"). The only way to get it "fixed" is to change the line this way:
.bday = CDate(el.birthday).toString("dd/MM/yy")
Is this the correct approach? Now that I have a nullable Datetime, how to handle the case when el.birthday is null?
Thanks!