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

  • Home
  • SEARCH
  • 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 152977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:43:09+00:00 2026-05-11T09:43:09+00:00

Reviewing Conery’s storefront, and I dont understand why he used Linqs auto-generated classes (ie

  • 0

Reviewing Conery’s storefront, and I dont understand why he used Linqs auto-generated classes (ie Order class) and then he has another Order class defined that is not a partial class. WHen using repository pattern should one manually create the classes, and disregard Datacontext altogether?

  • 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. 2026-05-11T09:43:10+00:00Added an answer on May 11, 2026 at 9:43 am

    If you don’t decouple your front end from the linq classes using an intermediary class, you can’t control with the data context gets garbage collected. Typically with data context types of instances you want to rid of them as soon as you’re done using them. Here’s how you might want to do this with the linq to sql context:

    using (MyDataContext data = new MyDataContext()) {     SomeThing thing = data.Things(t => t.ID == 1);     return thing; } ... the MyDataContext instance is gone 

    With the ‘using’ block, you’re disposing of the instance of MYDataContext at the last ‘}’. However, if you do this you’ll get an error then trying to use ‘thing’ because the data context instance is gone. If you don’t dispose of the data context, it’s left hanging around until it’s eventually garbage collected.

    If you introduce an intermediary class to decouple the linq to sql code from the calling app you can still get rid of your data context instance and return the same data (just in a different object):

    using (MyDataContext data = new MyDataContext()) {     SomeThing thing = data.Things(t => t.ID == 1);     SometThingElse otherThing = ConvertSomethingToSomethingElse(thing);     return otherThing; } ... the MyDataContext instance is gone 

    Hope that helps.

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

Sidebar

Related Questions

I'm currently reviewing/refactoring a multithreaded application which is supposed to be multithreaded in order
I have been reviewing a number of applications for securing deleting files. I understand
I was reviewing code and found that $(#item1 #item2) and $(#item1>#item2) are used interchangeably.
I'm reviewing a certain project and I see that there are many classes with
I'm reviewing for a class, and this is an old question: I need to
Edit : After reviewing the play, the example I used below is a tad
I'm reviewing an application currently experiencing problems with authentication (forms authentication is used combined
Whilst reviewing some Qt C++ code I came across this: class Foo { Q_OBJECT
Upon reviewing a bunch of MVC style web applications, I'm noticing that it's common
When reviewing on different OS's, I noticed that particularly in Chrome and Safari, words

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.