Need More Info
Last Updated: 11 Apr 2025 15:52 by ADMIN
Ken
Created on: 06 Apr 2025 11:33
Category: Grid
Type: Feature Request
1
Adjust DateTime Format in ToDataSourceRequest for SQL Server Compatibility

Please consider altering or providing configuration for how DateTime values are formatted in filter expressions generated by ToDataSourceRequest(). Currently, the format includes full precision (e.g., 2025-04-04T00:00:00.0000000), which causes issues when passed to Entity Framework Core with SQL Server, as SQL Server expects precision up to milliseconds (.fff), not ticks (.fffffff).

Why This Is a Problem

  • When passing filter expressions from ToDataSourceRequest() directly into a LINQ-to-EF query, the resulting SQL query fails if the DateTime string has 0000000 (7 digits of precision).
  • SQL Server’s datetime and datetime2 types don’t support nanosecond-level precision.
  • EF Core attempts to translate it, but fails with SQL conversion errors

 

1 comment
ADMIN
Nadezhda Tacheva
Posted on: 11 Apr 2025 15:52

Hi Kenneth,

The filter expressions generated by ToDataSourceRequest() are in a List of IFilterDescriptor. The IFilterDescriptor contains the dates as DataTime objects and not as strings in the format that you listed. Having that in mind, it is currently not clear how you are getting this format and hitting an issue with it. Can you provide more details and an isolated runnable sample showing your exact configuration?

In addition, can you please test the code without using the ToDataSourceRequest() and let me know if it still fails? We generally recommend using the ToDataSourceResult(request) method so it manages the operations for you when using OnRead which is different than  ToDataSourceRequest(). Can you please share what are you using the ToDataSourceRequest() for?

Last but not least, based on the information I found heredatetime2 types support nanosecond-level precision. Can you please share why are you left with the impression that they don't?

Regards,
Nadezhda Tacheva
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!