Given this expression:
var q = (from c in db.ContattiTitoliStudio
where ...
orderby c.Data descending
select new
{
c.ID,
Date = c.Data.ToString("MM dd, YYYY"),
});
c.Data is nullable, but also with a non-nullable var is the same:
“...No overload for method 'ToString' takes 1 arguments...“
I tried nullable, not nullable, with (c.Data!=null)..., with String.Format, with DateTime.Parse, etc… But I can’t format c.Date the way I want.
In SQL Server I use datetime as the type.
If I use normal Date = c.Date this will be displayed as “01/01/2011 0.0.00”.
Ok,finally this is the solution:
from msdn forums:
http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/208396f4-0406-41c6-b55f-0d8bb5d14b2c