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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:22:11+00:00 2026-06-06T13:22:11+00:00

I had an access to modified closure error in the code below foreach (var

  • 0

I had an access to modified closure error in the code below

foreach (var user in Entities.User)
            {
                bool any = Entities.Person.Any(
                    p => p.Name == user.Name);
            }

So I changed it to

foreach (var user in Entities.User)
            {
User theUser = user;
                bool any = Entities.Person.Any(
                    p => p.Name == theUser.Name);
            }

Now, the question is that I want to be able to modify a property of the user object. Does it matter if I do either of the following. Will they both save down to the database when I call SaveChanges on the DbContext?

user.Property = 1;

or

theUser.Property = 1;
  • 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-06T13:22:12+00:00Added an answer on June 6, 2026 at 1:22 pm

    Yes. User in this case is most likely a referencec type and thus variables of that type are just references pointing to an instance. The assignment just changes another variable to point to the same instance.

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

Sidebar

Related Questions

Until now, I've been the only person who has had access to the editing
I had a Invalid Cross Thread access issue, but a little research and I
I have had experiences of Reverse engineering and people taking access of your Database
I had a bunch of bookmark to www.asp.net/learn/, specially the one about data-access and
I've written a few Access db's and used some light VBA, and had an
I've messed with Access a little bit in the past, had one class on
I updated Ninject.MVC3 package from 2.2.1.0 to 2.2.2.0. Before I had access to the
I previously had code that used File.ReadAllLines() to read a text file and store
I had a bug, it went like this for(var i=0; i<arr.length; i++){ var v
Had this: $(function(){ $(a.next.down).click(function() { $(ul.panel li).addClass(upOne); $(a.next).removeClass(down).addClass(downTwo); }); $(a.next.downTwo).click(function() { $(ul.panel li).addClass(upTwo); $(a.next).removeClass(downTwo).addClass(downThree);

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.