I wanted to change my code-first project to SQL Server Compact 4.0.
But I have a problem with following LINQ expression
db.Test.OrderBy(t => t.Name)
.ThenBy(t => t.DayOfWeek)
.ThenBy(t => DbFunctions.CreateTime(t.TimeFrom.Hour, t.TimeFrom.Minute, t.TimeFrom.Second))
It throws the following error
The function 'CreateTime' is not supported by SQL Server Compact
Is there a way to write that expression without using the CreateTime
method?
I'm using code-first with Sql Server Compact. In my model I have a property called TimeStamp of type DateTime. At then I could do:
db.Test.OrderBy(t => t.Name)
.ThenBy(t => t.TimeStamp.DayOfWeek)
.ThenBy(t => t.TimeStamp.Hour)
.ThenBy(t => t.TimeStamp.Minute)
.ThenBy(t => t.TimeStamp.Second)
.ThenBy(t => t.TimeStamp.Millisecond);
or
db.Test.OrderBy(t => t.Name)
.ThenBy(t => t.TimeStamp.Ticks);