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 6991205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:27:58+00:00 2026-05-27T19:27:58+00:00

Part I I am working on a web application that instead of using a

  • 0

Part I
I am working on a web application that instead of using a viewmodel class to organize data and be used in View, uses a database table model. So for example in my view, model declaration looks like this: @model aa.webobjects.object – object is automatically generated by dbml. The question here is what is the benefit of using a viewmodel other than organizing data? I have another class, under dbml, that for example does this:

public Product GetProductsByPrice
{
    get
    {
        return WebDataContext.Get().Products.Where(x => x.Price > 10);
    }
}

And basically this is used to organize data, and pull data from database as needed. The return statement brings us to question two.

Part II
My application has a memory leak. The memory keeps growing and growing and after a while the server dies. As I read through some articles it seems like I should wrap my WebDataContext in using statement so that it’ll recycle properly. My question here is: is not using Viemodel causing the memory leak, ir if I used viewmodels to organize data, and reorganize usage of WebDataContext so that it’s wrapped in using statement would help?

I am not sure if this is explaining the problem correctly. Any help will be greatly appreciated.

  • 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-05-27T19:27:58+00:00Added an answer on May 27, 2026 at 7:27 pm

    For sure you have to dispose your DataContexts instances (that’s basically what using does). My suggestion is to add this in your Global.asax:

    public void Request_End(object sender, EventArgs e)
    {
        WebDataContext.Get().Dispose();
    }
    

    and make WebDatacontext.Get() to return it from HttpContext.Current.Items.

    In this way, your datacontext will be available for the whole request and it will be disposed when you don’t need it anymore.

    Hope it helps.

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

Sidebar

Related Questions

I'm working on a Ruby web Application that uses the Net::FTP library. One part
I'm currently working with a part of my application that uses Dynamic Web User
I am working on a data driven web application that uses a SQL 2005
All, I'm working on a web application for iOS that uses a fixed position
I'm working on an MVC3 web application using the razor view engine. I'm looking
I am working on a asp.net web application that has is a part of
I have a C# web forms ASP.NET 4.0 web application that uses Routing for
I have a web application which uses URLs that look like this: http://library.example.com/Register.aspx?query=academic&key=586c70bb-5683-419c-aae9-e596af9ab66a (The
I'm working on a web application that has some api calls that send arguments
I am working on a Silverlight application that uses WCF. I need to have

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.