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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:22:14+00:00 2026-05-11T12:22:14+00:00

I have been looking at the examples for updating models in the MVC architecture.

  • 0

I have been looking at the examples for updating models in the MVC architecture. There are plenty updating the model where the linq (SQL or EF) is in the controller. And there are others where the service layer is used to fetch values. The only example I can find its going to be awkward to use with an IoC container.

What I’m looking to be able to do, is fetch a model object update it in the controller and then pass it back in and actually do the saving in the Service Class or dater layer underneath.

At present I’m stuck with the data context in the service class fetching the object

    public User GetUser(string username)     {         return dc.UserSet.WithUsername(username);     } 

doing the updates in the controller with UpdateModel

and then calling SaveChanges through through the service interface and relying on the fact that the model object is still connected.

    public void Save()     {         dc.SaveChanges();     } 

What I want is to be able to call something like: public void Update(User User)

  • 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-11T12:22:15+00:00Added an answer on May 11, 2026 at 12:22 pm

    Were you looking for something like this?

    http://www.davidhayden.com/blog/dave/archive/2007/10/12/LINQToSQLAttachMethodAttachingDetachedBusinessEntitiesDataContextAttach.aspx

    You may or may not care about concurrency. Simple apps could probably get away with a last in wins approach but for larger apps you may need to research concurrency with linq to sql.

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

Sidebar

Related Questions

I have been looking at examples online, and tutorials, and I cannot find anything
I have been looking at EasyMock and tutorials/examples around using it for Unit Testing
I have been looking at many ASP.Net MVC client side validation ideas including xVal.
I have been looking at http://jqueryui.com/demos/sortable/#default most of the day. I would imaging updating
I have been looking at several examples for configuring a datasource for MySQL in
I have been looking around the internet for examples of an AJAX function which
I have been looking at the WF Wizard examples on endpoint.tv and here: http://stevenalexander.posterous.com/integrating-a-persisted-wf40-workflow-with-mv
I have been looking for C# examples to transform a DAG into a Tree.
I have been looking over some of the android source, and the examples given
Ok I have been looking for some good examples of Line of business apps

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.