Hello everybody, can someone please explain the difference between these 2 pieces of code:
var temp = (from c in Context.SomeTable
select new SomeObject { name=c.Name, created = c.Created}).ToList();
and this :
var temp = (from c in Context.SomeTable select c);
foreach(SomeTable t in temp)
{
SomeObject so = new SomeObject();
so.name = t.Name;
so.created = t.Created;
}
SomeTable.Created
is a nullable datetime type field in the database.
While the first piece throws an exception:
Sqldatetime overflow. must be between 1/1/1753 12:00:00 am and 12/31/9999 11:59:59 pm.
the second one works.
Thank You!