Skip to content

After upgrading from NET8 to NET10, Dynamic Linq "in" statement return different results in Debug or Release mode #987

Description

@hcd

Hi,

After upgrading our application fron .NET 8.0 to .NET 10.0, we got reports that our queries don’t return the correct number of entities anymore.

We’ve investigated and could pinpoint and extract the following case which demonstrates the broken behavior.

Consider the following simple code for a console app :

using System.Linq.Dynamic.Core;
 
namespace DynamicLinq
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var list = new List<MyEntity>();
            for (int i = 0; i < 10000; i++)
                list.Add(new MyEntity{Id= i});                
 
 
            var test1 = list.AsQueryable()
                .Where("Id in (9495, 9496, 9498, 9500, 9501, 9503, 9505, 9508, 9509, 9510, 9511, 9514, 9515, 9517, 9518, 9519, 9520, 9521, 9523, 9524, 9525, 9526, 9527, 9528, 9529, 9530, 9531, 9532, 9533, 9534, 9535, 9536, 9538, 9539, 9540, 9541, 9542, 9543, 9544, 9545, 9546, 9547, 9548, 9549, 9550, 9552, 9554, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9565, 9567, 9569, 9570, 9575, 9576, 9577, 9578, 9579, 9580, 9581, 9582, 9583, 9584, 9585, 9586, 9587, 9588, 9589, 9590, 9591, 9592, 9593, 9594, 9595, 9596, 9597, 9598, 9599, 9600, 9601, 9602, 9603, 9604, 9605, 9606, 9607, 9608, 9609, 9610, 9611, 9612, 9613, 9614, 9615, 9616, 9617, 9618, 9619, 9620, 9621, 9622, 9623, 9624, 9625, 9626, 9627, 9628, 9629)")
                .ToList();
 
            Console.WriteLine("Number of elements : " + test1.Count);  //should be 114 elements – but shows 64 when running in Release mode
        }
    }
 
    class MyEntity
    {
        public int Id { get; set; }
    }
}

When running this in Debug mode, it correctly shows correctly 114 elements. When running it in Release mode , it shows 64 elements

Also, this only happens in .NET 10.0 ...
When downgrading the console app to .NET 8.0 , both release and debug mode show 114 elements.

We consider this a quite serious bug, because it breaks things in our application and we see no workaround for it, except downgrading back to NET 8.0 (which would be a LOT of work …)

Kind regards,
Sven.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions