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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:05:32+00:00 2026-05-27T16:05:32+00:00

I am using Entity Framework for my Model layer, and I’d like to hook

  • 0

I am using Entity Framework for my Model layer, and I’d like to hook up a PropertyChanged event that changes another property based on the OldValue and NewValue of the property. Is there a built-in method I could hook into for this?

The basic logic I want in my PropertyChanged event is

if (oldValue.DefaultPropertyA == this.PropertyA)
    this.PropertyA = newValue.DefaultPropertyA;
  • 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-27T16:05:33+00:00Added an answer on May 27, 2026 at 4:05 pm

    You have the OnPropertyChanging partial method. There you will have access to the newvalue.

    The old value, is the value of the property on that moment, so you can access it just trough the regular property.

    The structure in your code generated file is like this:

        public global::System.String Property
        {
            get
            {
                return _Property;
            }
            set
            {
                OnPropertyChanging(value);
                ReportPropertyChanging("Property");
                _Property = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("Property");
                OnPropertyChanged();
            }
        }
    
        private global::System.String _Property;
        partial void OnPropertyChanging(global::System.String value);
        partial void OnPropertyChanged();
    

    As you can see, you can use the OnPropertyChanging and OnPropertyChanged partial methods to be notified of property changes.

    If you want to change the value of the property that’s being set, you can’t do this in a partial method. If you really want this you should change your T4 template to inject this code in your property or use Code First so you have direct access

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

Sidebar

Related Questions

I am getting started with Entity Framework 4, using model-first development. I am building
I'm using Visual Studio 2010 RTM with .NET/Entity Framework 4 RTM with a model
I'm using Entity Framework in my project, and I have the problem that, once
I'm using Entity Framework for creation of my Data Access Layer and I want
I am using Entity Framework to layer on my SQL Server 2008 database. The
I'm using Entity Framework to access my MySQL database. The model was generated using
What are the pros & cons of using Entity Framework 4.1 Code-first over Model/Database-first
I am using ADO.NET Mocking Context Generator plugin for my Entity Framework model. I
I have an MVC3 project using the Entity Framework model in which I've marked
I've got an Entity Framework 4 model. There's 2 tables in that model, Subscribers

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.