-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.ArgumentOutOfRangeException: 'Index was out of range. #1576
Comments
Looks like the "Allerretour" causes the problem. It is a bool (not nullable) and in database it is type bit(1) |
Could be related to dotnet/efcore#26428. |
@achilleaskar Are you using query filters? |
No only the where you can see. I also get the same problem in other application .Net 6 at this block of code query = query
.Where(t=> t.ExcursionDates.Any(d=> !includeDates || d.CheckOut >= DateTime.Today))
.OrderBy(e => e.ExcursionDates.Where(d => d.CheckIn >= DateTime.Today)
.OrderBy(ed => ed.CheckIn).FirstOrDefault().CheckIn);
var x = await query.Select(e => new ExcursionWithDatesDto
{
ExcursionDates = !includeDates ? new List<ExcursionDateDto>() : e.ExcursionDates
.Where(d => d.CheckOut >= DateTime.Today).Select(d => new ExcursionDateDto
{
Name = d.Name,
Id = d.Id,
NightStart = d.NightStart,
CheckIn = !d.NightStart ? d.CheckIn : d.CheckIn.AddDays(1), //change here
CheckOut = d.CheckOut
}).ToList()
}).ToListAsync(); The fourth line of the end is the fault of this error. If I change it to |
Hi! I reproduce same problem( https://github.com/vaital3000/net6efMysqlProblem I faced this problem after migration to net6 with ef core 6 and Pomelo.EntityFrameworkCore.MySql 6. |
@vaital3000 Could you try another database provider like SQLite or PostgreSQL to see if you have the same issue? |
I searched for hours, downloaded both efcore & pomelo repo to dig into this one and I found out that it's a known efcore 6 issue that is fixed and will be ok at 6.0.1 release of ef core. So just wait for it... |
OK, thanks for verifying that it was related to dotnet/efcore#26428 that was previously mentioned. |
FYI for those impacted by this issue: EF Core 6.0.1 is now available from NuGet. |
Steps to reproduce
It might be quite hard to reproduce because my project is very complex
The issue
I get a very strange error In one of my queries that works perfectly in the .Net Framework version of my app (there I use
MySql.Data.EntityFramework
)The query is this:
The problem occurs in
(completed || c.Services.Any(s => (s.Allerretour && s.TimeReturn >= DateTime.Today) || s.TimeGo >= DateTime.Today))
I get exception
System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')'
If I change it to
(completed || c.Services.Any(s => s.TimeReturn >= DateTime.Today || s.TimeGo >= DateTime.Today))
it works fine. The problem is in using two conditions. Any idea why this happens?Further technical details
MySQL version:
Operating system:
Pomelo.EntityFrameworkCore.MySql version: 6.0.0
The text was updated successfully, but these errors were encountered: