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.

ObjectDisposedException after update to v1.8.0

See original GitHub issue

I’ve been using v1.7.6 and my context calling looks like:

using (var db = new DataContext(context.ProviderName, context.ConnectionString))
{
        IEnumerable<someType> result = db.Where(<some search lambda>).AsEnumerable();
        return result;
}

After update to v1.8.0 I have an exception thrown:

System.ObjectDisposedException IDataContext is disposed Object name: ‘DataConnection’.

System.ObjectDisposedException: IDataContext is disposed Object name: ‘DataConnection’. at LinqToDB.Data.DataConnection.ThrowOnDisposed() at LinqToDB.Data.DataConnection.LinqToDB.IDataContext.SetQuery(IQueryContext queryContext) at LinqToDB.Linq.Query1.SetCommand(IDataContext dataContext, Expression expr, Object[] parameters, Int32 idx, Boolean clearQueryHints) at LinqToDB.Linq.Query1.<RunQuery>d__11.MoveNext() at LinqToDB.Linq.Query1.<Map>d__69.MoveNext() at System.Linq.Lookup2.Create[TSource](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) at System.Linq.GroupedEnumerable3.GetEnumerator() at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
MaceWinducommented, May 28, 2017

This change was introduced to fix issue when connection to database created after data context disposal. In that situation connection wasn’t returned to connection pool after use, which lead to connection pool exhaustion. If you need to defer your query execution, you should also defer disposal of data context.

0reactions
jogibear9988commented, May 30, 2017

No, it’s bad practice to use a Iqueryable outside of a using wich created the Iqueryable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ObjectDisposedException Class (System)
An ObjectDisposedException is thrown when you try to access a member of an object that implements the IDisposable interface or IAsyncDisposable interface, and ......
Read more >
ObjectDisposedException is thrown in CodeRush when VS ...
When CodeRush is loaded, I got an ObjectDisposedException when deleting some part of code. I have attached a video showing the Issue.
Read more >
c# - Using ObjectDisposedException
When implementing the Dispose pattern the object's properties should throw ObjectDisposedException after the object has been disposed.
Read more >
Changelog | Entities | 1.0.14
You can again have an unlimited number of Create/Update Before/After attributes. Includes unit tests. No documentation changes or additions were necessary.
Read more >
Software Version Changelog
DESKTOP-8410 Ref object disposed exception when entering capture mode with a force plate connected after playing recording with pressure.
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