Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > BOOK: Professional ASP.NET Design Patterns
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET Design Patterns
This is the forum to discuss the Wrox book Professional ASP.NET Design Patterns by Scott Millett; ISBN: 978-0-470-29278-5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET Design Patterns section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 6th, 2012, 02:20 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataContext Lifetime : Structure Map + EF

First of all this is a great book! I can't wait to read what you write next.
I have been looking for a book like this.

I am following along with the examples in your book.

I have a question about the DataContext lifetime.
I am following your code and looking at HttpDataContextStorageContainer
and how it uses HttpContext.Current.Items. I understand this is a "Per Http Request" usage.

My question is the DataContext getting properly disposed of and thus database connections getting closed?

In Sql Profiler I am showing some open connections after the Http Request has processed

I have read that the following may need to be used to dispose of the DataContext that stored in the HttpContext

Code:
        
protected void Application_EndRequest(object sender, EventArgs e)
        {
            ObjectFactory.ReleaseAndDisposeAllHttpScopedObjects();
        }
If the above is needed how does DataContext get setup in the BootStrapper?


Code:
For<IUnitOfWork>().HttpContextScoped().Use<EFUnitOfWork>();
        OR 
For<MyConcreteDataContext().HybridHttpOrThreadLocalScoped();
Does IDispose need to get implemented anywhere?

FYI: I am using EF 4.1, MS Sql, MVC3, Structure Map

Thanks in advance for any help!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic DataContext? softwarea BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 8 June 1st, 2009 01:04 PM
Creating a DataContext Schildb BOOK: Professional ADO.NET 3.5 with LINQ and the Entity Framework ISBN: 978-0-470-22988-0 1 April 14th, 2009 02:11 PM
Hashtable and lifetime of objects inside luca C# 3 February 19th, 2007 07:33 AM
CCommand Lifetime comdev2001 Oracle 0 November 29th, 2005 12:13 PM
Threads and an objects lifetime Kep C# 3 May 18th, 2004 01:11 AM



All times are GMT -4. The time now is 01:26 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.