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

The Archive Base Latest Questions

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

Is there a pre-built ModelBinder I can use with LINQ to get an object

  • 0

Is there a pre-built ModelBinder I can use with LINQ to get an object from a DataContext and update it on a HTTP post?

For example, currently I have this block of code:

[AcceptVerbs (HttpVerbs.Post)]
public ActionResult Edit (Project project)
{
    var projectService = Factory.GetService<IProjectService> ();
    project = projectService.GetProject (project.ProjectId);

    UpdateModel<Project> (project);

    if (!ModelState.IsValid)
        return View (project);

    project = projectService.SaveProject (project);

    return RedirectToAction ("Details", new { id = project.ProjectId });
}

(IProjectService wraps up calls to a LINQ data context)

In order to actually perform the update to the database via the LINQ data context, I need to get the project instance again and then update that instance.

Any attempt to simply save the project instance without first getting it from the data context results in nothing being written back to the database – I’m assuming because the LINQ data context knows nothing of the object it doesn’t do anything with it.

Using the Attach method on the Projects table class doesn’t work either btw, it throws an exception.

  • 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-12T09:09:02+00:00Added an answer on May 12, 2026 at 9:09 am

    You should look at the implementation in Mike Hadlow’s (new BSD) SutekiShop.

    In there you will find a DataBindAttribute and BindUsingAttribute which, if I understand correctly, do exactly what you want to do. Notice how the DataBindAttribute.Fetch property is used to rebind the incoming data, or not, (from an HttpPost) to a LINQ entity.

    I followed this pattern for one of my projects using ASP.NET MVC and LINQ-To-SQL. It works beautifully.

    Here’s the source: http://www.google.com/codesearch?hl=en&lr=&q=DataBind+package%3Ahttp%3A%2F%2Fsutekishop.googlecode.com&sbtn=Search

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

Sidebar

Related Questions

Is there a quick way to submit (pre-defined) POST data from a hyperlink in
I'm looking for a pre-built solution I can use in my RoR application. I'm
Can anyone suggest a better way to make a factory use a pre-built model
Are there any pre-existing solutions out there which would extend the built in SQL
Is there a way to get the C++ pre-processor to expand a #define'ed value
Is there anyway to restrict by using pre-processing directives to prevent a project from
Is there a canonical colorspace conversion library? I can't find any pre-existing solutions. Is
I've been trying to read a pre-built file with Car Maintenance tips, there's one
We have an NAnt script to update our pre-built assemblies in TFS as one
Is there any pre-built sample of iphone like bottom navigation using CSS 3? is

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.