Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8143705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:11:21+00:00 2026-06-06T13:11:21+00:00

Watching few examples that use repository pattern like StoreFront I couldn’t figure out where

  • 0

Watching few examples that use repository pattern like StoreFront I couldn’t figure out where is context.Dispose() called? Wouldn’t not disposing of data context lead to memory leaks? or is it just one Data context for each respoitory for the lifetime of application?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:11:22+00:00Added an answer on June 6, 2026 at 1:11 pm

    If you are using a using statement, which you should be doing, the call is automatically disposed as it implements the IDisposable interface.

    Such as:

    public int GetThingCount()
    {
        using (MyDataContext context = new MyDataContext())  // context is created here
        {
            return context.Things.Count();
        } // it is automatically disposed of here even in the event of an exception
    }
    

    http://msdn.microsoft.com/en-us/library/yh598w02.aspx

    As a rule, when you use an IDisposable object, you should declare and
    instantiate it in a using statement. The using statement calls the
    Dispose method on the object in the correct way, and (when you use it
    as shown earlier) it also causes the object itself to go out of scope
    as soon as Dispose is called. Within the using block, the object is
    read-only and cannot be modified or reassigned.

    The using statement ensures that Dispose is called even if an
    exception occurs while you are calling methods on the object. You can
    achieve the same result by putting the object inside a try block and
    then calling Dispose in a finally block; in fact, this is how the
    using statement is translated by the compiler. The code example
    earlier expands to the following code at compile time (note the extra
    curly braces to create the limited scope for the object):

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just watching a few videos on Channel9. I found things like lambdas
I'm making a web application that's focused around watching embedded content. I would like
I am watching Intro to Algorithms (MIT) lecture 1. Theres something like below (analysis
Watching a WWDC 2011, I saw advice (but not an explanation) that one should
After watching RailsCasts #273 I want to use the Geocoder gem. I've seen this:
I've been watching a video that stated that UIAlertView works only if UIKit.h has
I'm in the process of ironing out a few memory allocation issues in my
I'm trying to scrape a web app that uses a few redirects and logouts/logins
I have learnes objective-c and xcode by watching tutorials and trying out, so just
Like most .NET developers I was watching the keynote for the Build Event in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.