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 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

Ask A Question

Stats

  • Questions 255k
  • Answers 255k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It should be relatively simple to dump a table to… May 13, 2026 at 10:26 am
  • Editorial Team
    Editorial Team added an answer To find the File entry, you need to bring up… May 13, 2026 at 10:26 am
  • Editorial Team
    Editorial Team added an answer I am not sure, if one should use such a… May 13, 2026 at 10:26 am

Related Questions

The basics have already been answered here . But is there a pre-built PHP
My boss seems to think there's a way to play audio files via a
Setup I have a website that draws RSS feeds and displays them on the
In a little demo application that I'm building I put code to initialize the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.