I have a target per entity hierarchy. Lets say A->B->C.
That causes collections to be created - AEntityCollection, BEntityCollection and CEntityCollection.
At various times, I have a selection of records loaded from any of the collections. On these collections, there is at most one record that has a fieldX==true. So, if I were to create a property of the collection called ActiveRecord, where that property used an EntityView to locate that record and return it - where would I put that code?
Note, fieldX is a field that is in AEntity (so the others inherit it). Ideally, I would like to have this code in one place to share among all the collections - however, the collections do not inherit from each other - so........
Code would be like:
public CEntity ActiveRecord
{
get
{
CEntity activeRec = null;
if (this.Count > 0)
{
EntityView<CEntity> activeView = new EntityView<CEntity>(this, CFields.FieldX == true);
if (activeView.Count > 0)
{
activeRec = activeView[0];
}
}
return activeRec;
}
}
For now I have just duplicated the code in each collection class....