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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:27:31+00:00 2026-05-15T08:27:31+00:00

I am a tad befuddled. I can’t reason why the following works: AcceptVerbs(HttpVerbs.Post)] public

  • 0

I am a tad befuddled. I can’t reason why the following works:

    AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Edit(int id, FormCollection formValues) {
       Dinner dinner = dinnerRepository.GetDinner(id);
       UpdateModel(dinner);
       dinnerRepository.Save();
       return RedirectToAction("Details", new { id = dinner.DinnerID });
    }

The sample is taken from Scott Guthrie’s NerdDinner walkthrough, where dinnerRepository.Save() is defined as:

public void Save() {
   db.SubmitChanges();
}

And dinnerRepository.GetDinner(id) is defined as follows:

public Dinner GetDinner(int id) {
   return db.Dinners.SingleOrDefault(d => d.DinnerID == id);
}

Ie, how does the the db NerdDinnerDataContext “know” to save the dinner object?

There must be a hole in my understanding of Linq To SQL, but blowed if I can pin point it. OK, so the dinner object has an id, but what tells db that there are changes to submit for that specific record with that Id?

I just can’t see it. Must be the World Cup…

I can only think that the DataContext object, db, keeps a reference to the dinner object that was got using the GetDinner method call. But… It all feels a bit ‘magical’

Andrew

  • 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-15T08:27:32+00:00Added an answer on May 15, 2026 at 8:27 am

    You should look at the generated code for the LINQ to SQL classes. You’ll see that the property setters and getters for the classes contain change tracking so that the next time the repository is saved, the proper SQL statements are generated to commit any mutations made the the objects.

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

Sidebar

Related Questions

I was reading the code in the following link http://www.cosc.canterbury.ac.nz/tad.takaoka/alg/graphalg/sc.txt I kept bumping into
Accessing an array element with the following line works great; if (dataset[i].properties.property == value)
Edit : After reviewing the play, the example I used below is a tad
Basically I'm a tad confused. You'll see at http://furnace.howcode.com , in the second column,
I'm having a tad bit of trouble getting the jQuery Form Plugin to work
I'm a tad confused. I have a Repeater which populates a list of Checkbox
I have a mySQL database with a tad under 2 million rows. The database
So the title is a tad ambiguous, but I'll try and give an example.
One of the screens in my application has a high resolution background that can
I'm a tad confused. I am just getting started with OpenCV and its image

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.