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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:13:10+00:00 2026-05-12T13:13:10+00:00

You can refer to this post. I am getting these Extensibility methods from VS2008

  • 0

You can refer to this post.

I am getting these Extensibility methods from VS2008 in my Linq to sql Entity.

What are these auto generated extensibility methods good for?

#region Extensibility Method Definitions
    partial void OnCreated();
    partial void InsertPerson(Person instance);
    partial void UpdatePerson(Person instance);
    partial void DeletePerson(Person instance);
    #endregion

#region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIDChanging(int value);
    partial void OnIDChanged();
    partial void OnIDRoleChanging(System.Nullable<int> value);
    partial void OnIDRoleChanged();
    partial void OnLastNameChanging(string value);
    partial void OnLastNameChanged();
    partial void OnFirstNameChanging(string value);
    partial void OnFirstNameChanged();
    #endregion 

And these events?

public event PropertyChangingEventHandler PropertyChanging;

public event PropertyChangedEventHandler PropertyChanged;
  • 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-12T13:13:10+00:00Added an answer on May 12, 2026 at 1:13 pm

    They are there so you easily can add behaviour to the different stages of a linq-to-sql entity.

    For example the OnValidate method is incredibly useful if you want to hook in custom validation for certain properties of a class. Say for example you do not want FirstNames that contains the letter A to be allowed. You could simply add a partial version of the OnValidate method that sets the object as invalid like so:

     partial void OnValidate(System.Data.Linq.ChangeAction action) {
        if(FirstName.Contains('a') {
           //Do some custom code that prevents saving to the database and notifies the user.
        }
     }
    

    In addition to explain the two events. They are there so you can add custom logic whenever a property is changing or has changed. For example you might wanna log to database everytime a user changes his FirstName (for what reason I know not) then you could hook into the PropertyChanging event and add behaviour for that.

    Something like this might explain it better:

     this.PropertyChanging += new PropertyChangingEventHandler(User_PropertyChanging);
    

    and then a method to handle the event:

    void User_PropertyChanging(object sender, PropertyChangingEventArgs e)
        {
            //Add some code to log the change to database...
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.