LINQ To SQL
There are 2 entries for the tag
LINQ To SQL
A complete sample code project for this article is available here. In a previous post, I had proposed an idea on how to control the lifetime of the DataContext in LINQ to SQL (L2S). I basically created a provider class that would detect the presence of an HttpContext. If the context was present, it would use the HttpContext and store the DataContext on a per-request scope. Otherwise, it would store the DataContext in the CallContext, basically creating a per-thread scope for the DataContext. I actually felt a little dirty after having done this, but for some reason...
I’ve significantly altered the approach presented below in the following post. However, the post below may still be helpful for further reference. So I’ve been a user of NHibernate for a while on my main project at work. I got a change to refactor some services related to the application, and decided to use LINQ to SQL as the ORM, mainly so I could do a little more LINQ and check out the features of LINQ to SQL in a little more detail. One issue that seems to keep coming up among users is the lifetime of a DataContext. ...