ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Dotnet Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Remainder of EF-255 (triaged 2026-09-30). Random.Next(...) and Guid.NewGuid() now throw in a predicate, ordering or projection. These do not: Random.Shared.NextDouble(), NextSingle(), NextInt64() and Guid.CreateVersion7(). EF Core turns them into query parameters before the provider sees the expression, so they are evaluated once per execution and the same value is used for every row. Silent wrong result in all query modes.

      Repro

      Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      var r = context.Entities.Select(e => new { e.Id, R = Random.Shared.NextDouble() }).ToList();
      // every row has the same R (a fresh value on each execution)
      
      var w = context.Entities.Where(e => e.D > Random.Shared.NextDouble()).ToList();
      // all rows are compared against a single threshold
      

      Notes

      The Next-prefix match and the CreateVersion7 arm in NonDeterministicCalls never fire for these today because EF has already parameterized them. Options: detect the parameter extraction (query parameter whose expression is a non-deterministic call) and throw, or map NextDouble to the server rand operator. Both modes reach the same result, so a bridge-level or compiler-level check is needed rather than a method-call check.

            Assignee:
            Arthur Vickers
            Reporter:
            Arthur Vickers
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: