Looking great, can't wait! This is going to help us a lot. In fact, we're trying to hold off some functionality in our next release to coincide with your inheritance features as this feature will save us a lot of time.
What about inheritance of typed lists?
We currently have our own support classes to basically achieve this (see below). What we need to do is extend base typed lists with additional fields and filters. Sometimes we also extend base typed lists with some predicates but I guess this would be difficult to do (and not as important for us).
Our base class:
namespace MyProj.UntypedListClasses
{
[Serializable]
public abstract class UntypedListBase : TypedListBase
{
private ResultsetFields fields;
private IRelationPredicateBucket filterBucket;
protected UntypedListBase()
{
fields = new ResultsetFields(FieldCount);
filterBucket = new RelationPredicateBucket();
DefineFields();
DefineRelations();
}
protected UntypedListBase(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
// These aren't abstract so that derived classes always follow the same implementation pattern
// That is, derived classes always call base... before doing their own thing
protected virtual void DefineFields() {}
protected virtual void DefineRelations() {}
#region Properties
protected virtual int FieldCount
{
get { return 0; }
}
public ResultsetFields Fields
{
get { return fields; }
}
public IRelationCollection Relations
{
get { return FilterBucket.Relations; }
}
public IRelationPredicateBucket FilterBucket
{
get { return filterBucket; }
}
#endregion
public IRelationPredicateBucket GetRelationInfo()
{
return filterBucket;
}
public IEntityFields2 GetFieldsInfo()
{
return fields;
}
#region ITypedListCore Members
public override int Count
{
get { return this.Rows.Count; }
}
#endregion
}
}
Then we can go:
namespace MyProj.UntypedListClasses
{
public class PackageListUntypedList : UntypedListBase
{
private static int fieldCount = 54;
public PackageListUntypedList()
{
this.TableName = "PackageList";
}
protected PackageListUntypedList(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
protected override int FieldCount
{
get { return fieldCount + base.FieldCount; }
}
protected override void DefineFields()
{
base.DefineFields();
int i = base.FieldCount;
Fields.DefineField(DOCUMENTBASEFieldIndex.DOCUMENTKEY, i++, "DOCUMENTBASE_DOCUMENTKEY");
Fields.DefineField(DOCUMENTBASEFieldIndex.PUBLISHDATE, i++, "DOCUMENTBASE_PUBLISHDATE");
...etc...
}
protected override void DefineRelations()
{
base.DefineRelations();
Relations.Add(DOCUMENTBASEEntity.Relations.ACCOUNTINGDOCUMENTEntityUsingDOCUMENTBASEID, JoinHint.Left);
Relations.Add(DOCUMENTBASEEntity.Relations.PACKAGEEntityUsingDOCUMENTBASEID);
...etc...
}
}
}
and then we can derive again:
namespace MyProj.UntypedListClasses.ARUntypedList
{
[Serializable]
public class ARPackageListUntypedList: PackageListUntypedList
{
private static int fieldCount = 2;
public ARPackageListFullDetailsUntypedList()
{
}
protected ARPackageListFullDetailsUntypedList(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
protected override int FieldCount
{
get { return base.FieldCount + fieldCount; }
}
protected override void DefineFields()
{
base.DefineFields ();
int i = base.FieldCount;
Fields.DefineField(AGENTFieldIndex.AGENTKEY, i++, "AGENT_AGENTKEY");
Fields.DefineField(AGENTFieldIndex.NAME, i++, "AGENT_NAME");
}
protected override void DefineRelations()
{
base.DefineRelations();
Relations.Add(CONSUMEREntity.Relations.CONSUMERAGENTEntityUsingCONSUMERID);
Relations.Add(CONSUMERAGENTEntity.Relations.AGENTEntityUsingAGENTID);
Relations.Add(AGENTEntity.Relations.AGENTREPRESENTATIVEEntityUsingAGENTID);
Relations.Add(AGENTREPRESENTATIVEEntity.Relations.COREUSEREntityUsingCOREUSERID);
}
}
}