views:

58

answers:

1

I am creating an Entity Framework 4 application, and I need an unmapped property in one of my entities--my code will manage that property. What's the best way to create the property?

I assume I would create the property in a partial class for the entity, using code like this:

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 the property? Do I need to add anything else to the Setter? Thanks for your help.

A: 

You're doing it right. Note that calling ReportPropertyChanging/ReportPropertyChanged is optional : it is used for tracking by the ObjectContext (but the PropertyChanged can also be used for other things)

Thomas Levesque
Thanks--sounds like I can drop ReportPropertyChanging. I need PropertyChanged notification for WMP/MVVM, and I am guessing ReportPropertyChanged provides that.
David Veeneman