I'm trying to fetch some records from MSSQL DB using EntityObject with EntitySQL query. The field i'm using to filter is type of datetime. The generated query projected without millisecond, to the SQL Server returns nothing. When i'm adding the milliseconds, i get results.
How can i use the EntitySQL to get result without the milliseconds?
thanks.
It's not elegant, but this worked for me:
foos.SingleOrDefault(f => f.EntryDate.Year == bar.EntryDate.Year &&
f.EntryDate.Month == bar.EntryDate.Month &&
f.EntryDate.Day == bar.EntryDate.Day &&
f.EntryDate.Hour == bar.EntryDate.Hour &&
f.EntryDate.Minute == bar.EntryDate.Minute &&
f.EntryDate.Second == bar.EntryDate.Second);
One way to do it is to create a view of your data, where your datetime column is converted to smalldatetime (which does not have milliseconds).
Then add the view to your entity framework model, and read the data through the view.
Hope this helps
Shiraz
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With