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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:12:40+00:00 2026-05-24T12:12:40+00:00

I have 5 entities that are loaded using the entity framework. Here they are:

  • 0

I have 5 entities that are loaded using the entity framework. Here they are:
enter image description here
All of the entities are inherited from:
enter image description here

(Each entity represented by a class with the properties described above. Al entities inherit Transmission entity).
As you can see, there are common properties in some of the entities. But the properties WorkerId, WorkerPersonalId, VehicleId, VehicleNumber, SubcontractorId has special methods for SET so in order to encapsulate the logic of update I created WorkerVehicleTransmission class with those properties setters implementation. Each transmission now uses the WorkerVehicleTransmission.
Now I have a new need. I need to log each property change. For that I have the Log() method. For eaxmple, I need that when the user makes cargoStorage.Weight=8; there will be a call to Log() that will log this change.

Importent issue: I need to find a solution where the creation of an entity (by the entity framework for example) will not log.

How can I integrate the new need?

This question is the real need for the example I ask about here: how to solve this code duplication + add another method

  • 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-24T12:12:40+00:00Added an answer on May 24, 2026 at 12:12 pm

    As a start you could attach a handler to the PropertyChanged event in the Transmission base class which will enable you to call the Log method whenever a property changes in any of your sub classes.

    INotifyPropertyChanged.PropertyChanged Event

    This however will fire when any change is made, including when the Entity Framework creates the objects, so is only half way there.


    Edit

    If you create a new property within the Transmission class (a boolean flag) you could use this in your data access object routines to set whether logging should be enabled.

    This flag is only ever set after any Entity Framework activity on each object has been completed therefore the only Property changes logged are those relating to your code.

    Not an elegant solution but I cannot see any other way.


    Edit

    Just had a look at the EntityObject base members and there is an Property (Enumeration) named EntityState.

    EntityObject.EntityState Property

    This property is set to “Detached” when the entity is being created (Unattached to the object context) by the Entity Framework and changes its value to “Added”, “Deleted”, “Modified” or “Unchanged” after it is added (depending on the state of the object).

    By checking if the value is anything other than “Detached” you could then determine whether logging should be enabled.

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

Sidebar

Related Questions

If I have entities that inherit from a base entity (say Widgets, Gadgets, and
I have a some JPA entities that inherit from one another and uses discriminator
I'm building an ASP.NET MVC site using the ADO.NET Entity Framework. I have an
I have an ObservableCollection<T> (T being a set of entities loaded using OData) which
I have 3 entities: RatedPrice, DailyPrice and UtilizePrice. Each entity has Code member. I
I have a situation where I have two entities that share a primary key
So I have an IList of business entities that I loop through in a
Should entities have behavior? or not? Why or why not? If not, does that
I have a Dynamic Data Entities Web Application that uses a database with GUIDs
I'm hand-coding Linq to SQL Entities and have a large XML column that I

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.