i have entity type called doctor have created model can use inotifypropertychange on items in entity. in model called doctormodel, have following function give me exception:
unable cast object of type 'ms.internal.namedobject' doctormodel
// overloaded methods public override int gethashcode() { return id ^ 7; } public override bool equals(object obj) { // check null if (referenceequals(obj, null)) return false; // check same reference if (referenceequals(this, obj)) return true; var model = (doctormodel)obj; <-- exception here --> return this.id == model.id; } edit: creating observablecollection of type when try remove element, not remove it. saw article on site showed use technique when tying described. article referring @ following: http://www.c-sharpcorner.com/uploadfile/tirthacs/remove-an-item-form-observable-collection-using-remove/
just posting solution question in case else benefit it.
public override int gethashcode() { return string.format("doctormodel{0}", this.id.tostring()).gethashcode(); } public override bool equals(object obj) { var newobj = obj doctormodel; if (null != newobj) { return this.gethashcode() == newobj.gethashcode(); } else { return base.equals(obj); } }
Comments
Post a Comment