Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Edited Issue: Auto-compiled queries don't work correctly with DateTime and DateTimeOffset constant values that differ in the millisecond range [1243]

$
0
0
When EnablePlanCaching is true, executing two queries in sequence when the only difference between the queries is between DateTime/DateTimeOffset constant value (in the milliseconds range), the second query always returns the same result as the first query.

As a result, incorrect data might be read.

The issue seems to be in ExpressionKeyGen class, where comparison is done via string representations of the expressions, where milliseconds values are clipped (ie precision is captured including seconds but not milliseconds.)

This seems to be related to the precision of DateTime and DateTimeOffset, but we should investigate similar issues with other primitive types as well.

Workarounds:
- Disabling caching on the query, easier in the ObjectContext API than on DbContext.
- Parameterize all the constants of the types affected by assigning the values to variable, and referencing the variable in the query, which should prevent the value to be copied into the query key as a string

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>