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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:38:18+00:00 2026-06-17T22:38:18+00:00

Ok, here is how I update a single object: public void UpdateRespondent(Respondent changed) {

  • 0

Ok,

here is how I update a single object:

public void UpdateRespondent(Respondent changed)
{
    var respondent = db.Respondents.FirstOrDefault(r => r.RespondentId == changed.RespondentId);

    db.Respondents.ApplyCurrentValues(changed);
    db.SaveChanges();
}

This will invoke 1 select and 1 update (if something changed).

Now, if I have a List<Respondent> with hundreds of them, how do I do that, call UpdateRespondent(changed) on each one in a loop? That will result in hundreds * 2 sql statements.

Or is there a more efficient way to do this?

Thanks.

  • 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-06-17T22:38:20+00:00Added an answer on June 17, 2026 at 10:38 pm

    EF does not support batch updates. You can look into using EntityFramework Extended Library — I’ve seen others who’ve had success using it:

    https://github.com/loresoft/EntityFramework.Extended

    Code sniplet from above link:

    //update all tasks with status of 1 to status of 2
    context.Tasks.Update(
        t => t.StatusId == 1, 
        t2 => new Task {StatusId = 2});
    
    //example of using an IQueryable as the filter for the update
    var users = context.Users.Where(u => u.FirstName == "firstname");
    context.Users.Update(users, u => new User {FirstName = "newfirstname"});
    

    Alternatively, you could use straight ADO.Net and call a stored proceudre.

    Good luck.

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

Sidebar

Related Questions

I've got a dependency object that defines a single depedendency property named Renderer. public
I found something that works with updating one field at here: http://www.karlrixon.co.uk/articles/sql/update-multiple-rows-with-different-values-and-a-single-sql-query/ UPDATE person
Update : Here is the project. I have the following directory structure: RMI |
Update In the wiki spirit of StackOverflow, here's an update: I spiked Joe White's
Here is my upsert code: UPDATE LastTicket SET LastTicketNumber=LastTicketNumber+1 OUTPUT INSERTED.LastTicketNumber WHERE CategoryId='1'; IF
Here is my chunk of code: var update_shipping_methods = function(methods) { $(methods).each( function(i) {
UPDATE: Based on suggestions here, I've modified my code. To get a handle on
here's my question: I have an MVC3 C# application and I need to update
I have a query here regarding the value given to the update attribute of
Here I have piece of code, showing example of how I want to update

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.