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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:25:12+00:00 2026-05-14T16:25:12+00:00

I am using ASP.NET DynamicData (based on LINQ to SQL) on my site for

  • 0

I am using ASP.NET DynamicData (based on LINQ to SQL) on my site for basic scaffolding. On one table I have added additional properties, that are not stored in the table, but are retrieved from somewhere else. (Profile information for a user account, in this case).

They are displayed just fine, but when editing these values and pressing “Update”, they are not changed.

Here’s what the properties look like, the table is the standard aspnet_Users table:

 public String Address
    {
        get
        {
            UserProfile profile = UserProfile.GetUserProfile(UserName);
            return profile.Address;
        }

        set
        {
            UserProfile profile = UserProfile.GetUserProfile(UserName);
            profile.Address = value;
            profile.Save();                
        }
    }       

When I fired up the debugger, I’ve noticed that for each update the set accessor is called three times. Once with the new value, but on a newly created instance of user, then once with the old value, again on an new instance, and finally with the old value on the existing instance.

Wondering a bit, I checked with the properties created by the designer, and they, too, are called three times in (almost) the same fashion. The only difference is, that the last call contains the new value for the property.

I am a bit stumped here. Why three times, and why are my new properties behaving differently? I’d be grateful for any help on that matter! =)

  • 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-14T16:25:12+00:00Added an answer on May 14, 2026 at 4:25 pm

    I observed something similar when I let Linq to SQL use stored procedures for inserting/updating. I am not sure if I remember correctly, but I think that Linq to SQL uses these three instances of the entity class to figure out what changed so that the required SQL statement can be built.

    I see basically two options (though I am not sure if this really works):

    1. You could probably store the extra field(s) in the “OnValidate” event of the entity.
    2. You could overwrite the partial methods for inserting/updating. In that case you will also need to take care of storing the entity in the database (e.g. with stored procedure).

    The property would look then like this:

    private string address = null;
    public string Address
    {
        get
        {
            if (this.address == null)
            {
                 // Load on first use: This might make a problem...
                 UserProfile profile = UserProfile.GetUserProfile(UserName);
                 this.address = profile.Address;
            }
            return this.address;
        }
    
        set
        {
            this.address = value;                      
        }
    }   
    

    In both cases you have the problem that you might update the extra fields though the update of the rest of the entity fails. This was of course also a problem with your initial approach.

    I think the best solution would be to implement your own profile provider and store the profile information in your own tables. If you do that you could let Linq to SQL create entities for your profile information: Everything would be “standard” and you would not have to resort to some kind of “hack”…

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

Sidebar

Ask A Question

Stats

  • Questions 382k
  • Answers 382k
  • 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 Delphi 7 and all the versions till D2006 has also… May 14, 2026 at 10:25 pm
  • Editorial Team
    Editorial Team added an answer HttpUtility.HtmlEncode only encodes characters that are "reserved" in HTML. For… May 14, 2026 at 10:25 pm
  • Editorial Team
    Editorial Team added an answer The first parameter to hook_form is $node. If $node->nid is… May 14, 2026 at 10:25 pm

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.