Skip to content

EF Core 11 rewrites RangeSet.Contains into Queryable.Contains over the range type and throws ArgumentException #287

Closed

Description

@CaffeinatedCoder

Problem

RangeSet<TRange, T> is an IReadOnlyList<TRange>. EF Core 11 (dotnet/efcore#37081, PR 37390) normalizes every method named Contains on an IReadOnlyCollection<T> into Queryable.Contains<T>(AsQueryable(obj), arg) before any translator runs, with T the collection's element type, TRange. set.Contains(T value) and set.Contains(RangeSet) then fail inside EF Core:

System.ArgumentException: Expression of type 'System.DateOnly' cannot be used for parameter of type 'CodoMetis.ValueRanges.DateRange' of method 'Boolean Contains[DateRange](IQueryable`1[DateRange], DateRange)'
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryableMethodNormalizingExpressionVisitor.TryConvertCollectionContainsToQueryableContains

On net11.0 / EF Core 11 RC1 this fails QueryTranslationTests.RangeSet_Contains_*, ExecutedQueryTests.MultirangeComparisons_MatchInMemory, MultirangeCoverageTests, the InfinityDisabled extremes test and the NodaTime YearMonthRangeSet tests: every RangeSet.Contains in a query throws. Loud, not silent.

The same change was merged into release/10.0 on 2026-10-02 (dotnet/efcore#39114) and is not in EF Core 10.0.13; the 10.x line meets it with the first EF Core 10 patch that carries it (see the 10.x issue).

Change

The query interceptor rewrites the three instance overloads into static methods on RangeSetContains, whose declaring type is not a collection, and the method call translator translates that form to @> exactly as the instance call. Public API unchanged.

Found by the #103 retarget's first test run.

Activity

  1. added this to the 11.0.0 milestone on Oct 19, 2026
  2. added
    bugSomething isn't working
    area/range-setRangeSet and multirange algebra
    package/efcoreAffects CodoMetis.ValueRanges.EFCore.PostgreSQL
    package/efcore-nodatimeAffects CodoMetis.ValueRanges.EFCore.PostgreSQL.NodaTime
    severity/highWrong results, crash or failed writes in a realistic scenario
    on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/range-setRangeSet and multirange algebrabugSomething isn't workingpackage/efcoreAffects CodoMetis.ValueRanges.EFCore.PostgreSQLpackage/efcore-nodatimeAffects CodoMetis.ValueRanges.EFCore.PostgreSQL.NodaTimeseverity/highWrong results, crash or failed writes in a realistic scenario

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions