question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Npqsql 5.0.0-rc.1 - System.ArgumentOutOfRangeException : Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')

See original GitHub issue

Describe your issue

For some reason some Xunit integration tests in my project fail with npgsql error (invoked by Linq2Db) Executing the tests “all tests in file” only - no error occurrs.

It crashes with this query:

grafik

grafik

So the query is executed but the result cannot be read.

Unfortunately I cannot provide an reproducible example since the error only occurs if dotnet test is used - there are hundreds of tests. All Xunit test classes running against Postgres are decorated with [Collection("PostgresSequential")]

await context.Aggregates
            .Where(x => x.AggregateId == aggregateId)
            .Set(x => x.LastDispatchedVersion, lastDispatchedVersion)
            .UpdateAsync();

Environment details

Linq To DB version: 5.0.0-rc.1

Database (with version): Postgres latest

ADO.NET Provider (with version): ? (e.g. Microsoft.Data.SqlClient 4.1.0)

Operating system: ?

.NET Version: 6

Issue Analytics

  • State:closed
  • Created 7 months ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
jods4commented, Feb 16, 2023

@HypeillingerChillinger that first example is wrong. You are disposing the context as soon as UpdateMeAsync returns, but at this point UpdateAsync is likely to not being complete. This is bad concurrent code.

0reactions
HypeillingerChillingercommented, Feb 16, 2023

Ok, the query is already in outer space. Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.ArgumentOutOfRangeException: Index was out of ...
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter ...
Read more >
Index was out of range · Issue #2628
ArgumentOutOfRangeException : 'Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')' ...
Read more >
How do I resolve index was out of range. Must be non- ...
The most likely cause is that the number of rows returned from your query is not the same as the number of elements...
Read more >
index was out of range. Must be non-negative and less ...
The error message is pretty explicit: Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: ......
Read more >
Index was out of range. Must be non-negative and " ...
The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found