Hi,
I have a problem, I have added a new entity to a collection, and assigned it a GUID (I am using these as primary key values in this case).
foreach (IEntityField2 field in targetEntity.PrimaryKeyFields)
targetEntity.Fields[field.Name].CurrentValue = entity.Fields[field.Name].CurrentValue;
targetEntity.IsNew = false;
int index = n.IndexOf(targetEntity);
I am trying to find the entity based on its' primary key value.
I cannot seem to do this as the IndexOf method compares references instread of key values.
<snippit from EntityBase2>
// new entities are always different. If one of the two (this, or passed in object) is new, they have to be tested using reference testing.
// if that fails, they're not the same. New entities can't be compared using field values
if(this.IsNew || passedIn.IsNew) {
// one or both is new, use instance compare.
bool ba = this.IsNew;
bool bb = passedIn.IsNew;
return (this==passedIn);
}
My problem is:
How do I search for an entity based on its key value (or any other value for that matter) when it may be a new entity or it may not. Does a simple search of this nature exist?
Regards
Craig