EF4: How to create an unmapped property?

I am creating an Entity Framework 4 application, and I need a non-displayed property in one of my entities - my code will manage this property. What is the best way to create a property?

I assume that I will create a property in a partial class for the entity using this code:

private byte[] _Foo;
public byte[] Foo
{
    get
    {
        return _Foo;
    }
    set
    {
        if (value == _Foo) return;
        ReportPropertyChanging("Foo");
        _Foo = value;
        ReportPropertyChanged("Foo");
    }
}

Is there a better way to create a property? Do I need to add anything else to Setter? Thank you for your help.

+3
source share
1 answer

You are doing it right. Please note that calling ReportPropertyChanging/ ReportPropertyChangedis optional: it is used to track with ObjectContext(but PropertyChangedcan also be used for other purposes)

+1
source

Source: https://habr.com/ru/post/1743803/


All Articles