How can I add an “IsDirty” property to a LINQ to SQL entity?

后端 未结 1 379
一整个雨季
一整个雨季 2021-01-15 15:21

I am binding my entities to an edit form in WPF. Within a DataTemplate, I want to be able to set the background color of the root container within a DataTemplate to show it

相关标签:
1条回答
  • 2021-01-15 16:09

    If you are using the dbml generated classes, you should be able to implement a couple of partial methods like this:

    public partial class SampleEntity
    {
        partial void OnCreated()
        {
            this.IsDirty = true;
        }
    
        partial void OnLoaded()
        {
            this.PropertyChanged += (s, e) => this.IsDirty = true;
            this.IsDirty = false;
        }
    
        public bool IsDirty { get; private set; }
    }
    
    0 讨论(0)
提交回复
热议问题