반응형
    [Table]
    public class AddTableNameHere : INotifyPropertyChanged, INotifyPropertyChanging
    {

        //
        // TODO: Add columns and associations, as applicable, here.
        //

        // Version column aids update performance.
        [Column(IsVersion = true)]
        private Binary _version;

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        // Used to notify that a property changed
        private void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion

        #region INotifyPropertyChanging Members

        public event PropertyChangingEventHandler PropertyChanging;

        // Used to notify that a property is about to change
        private void NotifyPropertyChanging(string propertyName)
        {
            if (PropertyChanging != null)
            {
                PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
            }
        }

        #endregion
    }

이것은 로컬 데이터베이스 테이블을 나타내는 클래스인 엔터티의 기본 템플릿입니다. 대부분의 엔터티에 공통적으로 적용하는 것이 좋은 다음 코드 기능을 보여 주기 위해 지금은 열과 연결이 빠져 있습니다.

  • [table] 특성은 클래스가 데이터베이스 테이블을 나타내도록 지정합니다.

  • INotifyPropertyChanged 인터페이스는 변경 추적에 사용됩니다.

  • INotifyPropertyChanging 인터페이스는 변경 추적과 관련된 메모리 사용을 제한하는 데 유용합니다.

  • [Column(IsVersion = true)] 특성이 있는 Binary 버전 열은 테이블 업데이트 성능을 크게 향상시킵니다.


반응형
Posted by 컴스터
,