Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><em>Note: the following advice holds for all O/RM tools that implement the unit of work pattern such as Entity Framework's <code>ObjectContext</code>, <code>DbContext</code>, NHibernate's <code>Session</code>, and LINQ to SQL's <code>DataContext</code>.</em></p> <p>The LINQ to SQL DataContext is NOT thread-safe. You should create (at least) 1 context per web request. Reusing the same instance over multiple threads means that one thread can call <code>SubmitChanges</code> while another thread is still inserting new objects. If you're lucky the <code>DataContext</code> will throw an exception, because it cannot persist the changes. If you're unlucky, the <code>DataContext</code> succeeds and you break the atomicy of a single request, which can cause you to have inconsistent data in your database. In other words: You'll have a database full of shit!</p> <p>Besides that, the <code>DataContext</code> keeps all objects in its cache, which mean that the memory consumption of your application will keep growing, which can lead to an <code>OutOfMemoryException</code> (OOM). And even if you won’t get an OOM, the objects in the cache get stale and especially if other applications or processes are updating your database, you will never see those changes when an entity is already in memory. And last thing to note is that there is no way for you to rollback changes made in the <code>DataContext</code> so when you (at one point) invalidated the <code>DataContext</code> (because of errors) there is no way to restore this (except from creating a totally new <code>DataContext</code>). In that case your AppDomain is doomed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload