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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:18:11+00:00 2026-06-17T21:18:11+00:00

I am trying to use the calculated columns to display in my grid. I

  • 0

I am trying to use the calculated columns to display in my grid.

I have a partial class automatically generated by EF code generator with three properties:

Here is my code generated by EF entity generator

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated from a template.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
using System.ComponentModel.DataAnnotations;

namespace Employees.Contract
{
[DataContract(IsReference = true)]
[KnownType(typeof(Department))]
[KnownType(typeof(PropertyType))]
public partial class Employee: IObjectWithChangeTracker, INotifyPropertyChanged,IDataErrorInfo
{

    [NonSerialized]
    private CLOS.Contract.Validation.DataErrorInfoSupport dataErrorInfoSupport;

    public Employee()
    {            
        dataErrorInfoSupport = new CLOS.Contract.Validation.DataErrorInfoSupport(this);
        Init();
    }

    partial void Init();

    string IDataErrorInfo.Error { get { return dataErrorInfoSupport.Error; } }

    string IDataErrorInfo.this[string memberName] { get { return dataErrorInfoSupport[memberName]; } }

    #region Primitive Properties


    [DataMember]
    public Nullable<decimal> Salary
    {
        get { return _salary; }
        set
        {
            if (_salary != value)
            {
                _salary = value;
                OnPropertyChanged("Salary");
            }
        }
    }
    private Nullable<decimal> _salary;

    [DataMember]
    public Nullable<decimal> WageRate
    {
        get { return _wageRate; }
        set
        {
            if (_wageRate != value)
            {
                _wageRate = value;
                OnPropertyChanged("WageRate");
            }
        }
    }
    private Nullable<decimal> _wageRate;

    [DataMember]
    public Nullable<decimal> Bonus
    {
        get { return _bonus; }
        set
        {
            if (_bonus != value)
            {
                _bonus = value;
                OnPropertyChanged("Bonus");
            }
        }
    }
    private Nullable<decimal> _bonus;

    #endregion
    #region Navigation Properties

    [DataMember]
    public Department Department
    {
        get { return _department; }
        set
        {
            if (!ReferenceEquals(_department, value))
            {
                var previousValue = _department;
                _department = value;
                OnNavigationPropertyChanged("Department");
            }
        }
    }
    private Borrower _department;

    [DataMember]
    public PropertyType PropertyType
    {
        get { return _propertyType; }
        set
        {
            if (!ReferenceEquals(_propertyType, value))
            {
                var previousValue = _propertyType;
                _propertyType = value;

                OnNavigationPropertyChanged("PropertyType");
            }
        }
    }
    private PropertyType _propertyType;

    #endregion
    #region ChangeTracking

    protected virtual void OnPropertyChanged(String propertyName)
    {
        if (ChangeTracker.State != ObjectState.Added && ChangeTracker.State != ObjectState.Deleted)
        {
            ChangeTracker.State = ObjectState.Modified;
        }
        if (_propertyChanged != null)
        {
            _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    protected virtual void OnNavigationPropertyChanged(String propertyName)
    {
        if (_propertyChanged != null)
        {
            _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged{ add { _propertyChanged += value; } remove { _propertyChanged -= value; } }
    private event PropertyChangedEventHandler _propertyChanged;
    private ObjectChangeTracker _changeTracker;

    [DataMember]
    public ObjectChangeTracker ChangeTracker
    {
        get
        {
            if (_changeTracker == null)
            {
                _changeTracker = new ObjectChangeTracker();
                _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
            }
            return _changeTracker;
        }
        set
        {
            if(_changeTracker != null)
            {
                _changeTracker.ObjectStateChanging -= HandleObjectStateChanging;
            }
            _changeTracker = value;
            if(_changeTracker != null)
            {
                _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
            }
        }
    }

    private void HandleObjectStateChanging(object sender, ObjectStateChangingEventArgs e)
    {
        if (e.NewState == ObjectState.Deleted)
        {
            ClearNavigationProperties();
        }
    }

    protected bool IsDeserializing { get; private set; }

    [OnDeserializing]
    public void OnDeserializingMethod(StreamingContext context)
    {
        IsDeserializing = true;
    }

    [OnDeserialized]
    public void OnDeserializedMethod(StreamingContext context)
    {
        dataErrorInfoSupport = new CLOS.Contract.Validation.DataErrorInfoSupport(this);
        IsDeserializing = false;
        ChangeTracker.ChangeTrackingEnabled = true;
    }

    protected virtual void ClearNavigationProperties()
    {
        Department = null;
        PropertyType = null;
    }

    #endregion
}

}

It also works if i put OnPropertyChanged("Salary") in Hours,Wage,Overtime Property in EF Generated class (which is not a good idea) because if the class gets regenerated , my code will be wiped out

Any help is appreciated. (Sorry for the formatting , this is my first question)

Thanks

  • 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-17T21:18:12+00:00Added an answer on June 17, 2026 at 9:18 pm

    I was able to fix this issue. What was happening is that service was marshaling the data back to the UI but it was not marshaling the events with the properties, so what i had to do was to call the init method from the UI and it started working.

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

Sidebar

Related Questions

I have a select statement with calculated columns and I would like to use
I am trying use gem tire to search in my application. I have tables
I'm trying to use TF-IDF to sort documents into categories. I've calculated the tf_idf
I have 2 tables that I'm trying to use to perform some calculations. My
In Access 2010 I am trying to use custom VBA functions in a calculated
I have three columns in my wx.ListCtrl(size=(-1,200)) . I would like the columns to
I'm trying to implement generic method to put in a class a calculated value
I am trying to create a SQL Server 2008R2 Table column with automatically calculated
I'm trying to use the RQuantLib package to calculate greeks for some options but
I'm trying to use the position of the mouse to calculate the scaling factor

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.