ASP.NET and LINQ

One of the problems you may experience is the issue of postbacks with the "staleness" of queried data.  Because ASP.NET is stateless, when after unloading resources, all previously known resources are gone.  A common way to keep data around is to store it in the cache.  So if there is a commonly referenced LINQ business object in an ASP.NET site, it can be cached in the system.

The problem you may experience with this is that you can't use the object in certain situations.  You may get an error stating that the object isn't new and wasn't queried with the current instance of the data context class; this is because an object originally queried on the first page load is cached, the data context is destroyed, and on the next load, the cached object is retrieved.

This object can be used to reference it's child data, especially if you've loaded the related data in an immediate fashion.  What I experienced is an issue with updating data using this object or its related data as a reference.  If you assign the object reference to a recently queried object, you may get an error stating that the object isn't new and isn't known by the current data context.

A solution could be to cache the data context; I personally don't like to do that because that's a lot of data to store in the cache (depending on the size of the application).

Published Wednesday, April 30, 2008 4:55 AM by bmains
Filed under: ,

Comments

No Comments

The leading UI suite for ASP.NET - Telerik radControls
Outstanding performance. Full ASP.NET AJAX support. Nearly codeless development.