vb.net - How do I implement the OnPropertyChanged event in the generated code of my entity Model in partial classes that I add -
i have entity data model built using devart's entity developer. database first model , set template properties implement inotifypropertychanged (and changing) , create separate partial classes each entity in model.
with model built looking @ auto generated code in model property of entity looks this:
public overridable property rc() global.system.nullable(of integer) return _rc end set if (object.equals(_rc, value) = false) onpropertychanging("rc") _rc = value onpropertychanged("rc") end if end set end property private _rc global.system.nullable(of integer)
with further sections relating inotifypropertychanged , changing:
#region "inotifypropertychanging members" public event propertychanging(sender object, e propertychangingeventargs) implements inotifypropertychanging.propertychanging protected sub onpropertychanging(propertyname string) raiseevent propertychanging(me, new propertychangingeventargs(propertyname)) end sub #end region #region "inotifypropertychanged members" public event propertychanged(sender object, e propertychangedeventargs) implements inotifypropertychanged.propertychanged protected sub onpropertychanged(propertyname string) raiseevent propertychanged(me, new propertychangedeventargs(propertyname)) end sub
the model created separate partial class entity , assume should in partial class should put code want react onpropertychanged. example property illustrated in code snippet above (which typically represent year in form of 2014) set value of of entities properties 2014 + 5 ie 2019.
could explain me how should this. i'd prefer vb if possible can work c#.
thanks
for benefit of others may come @ point in future.
i had entity model built in own project (so in effect separate data layer) couple of solutions building. each entity has own separate partial class add custom code. knew need handle propertychanged event in partial class struggling 'see' property had fire event.
it turns out had made simple fundamental mistake. had created following method:
private sub onpropertychangedlogicimplementation(sender object, e eventargs) handles me.propertychanged select case e.propertyname case end select end sub
the reason didn't work had used eventargs opposed propertychangedeventargs couldn't pick propertyname expecting able pick up.
private sub onpropertychangedlogicimplementation(sender object, e propertychangedeventargs) handles me.propertychanged select case e.propertyname case end select end sub
oddly there little in way of direct examples of how find , hence original question. save else wasting time looking painfully obvious (once of course realise it's painfully obvious!).
Comments
Post a Comment