Hi,
all my table have an integer field called "Version" and I need the maximum of the current values.
My goal is to have a general function that executes an aggregate function on a collection of which I just know the name.
This is what I have done so far:
//Sample calls
int maxCustomers = GetMaxVersion("Customers");
int maxProducts = GetMaxVersion("Products");
public int GetMaxVersion(String entityName)
{
int result = 0;
entityName += "Entity";
//Find out corresponding entity type
EntityType typeOfEntity = (EntityType)Enum.Parse(typeof(EntityType), entityName, false);
//Create a new collection instance based on typeOfEntity
IEntityCollection myCollection = FactoryClasses.GeneralEntityCollectionFactory.Create(typeOfEntity);
//I HAVE NO IDEA HOW TO COMPLETE THE FOLLOWING LINE
int result = (int)???.GetScalar(???FieldIndex.Version, SD.LLBLGen.Pro.ORMSupportClasses.AggregateFunction.Max);
return result;
}
My problem is the last statement in the GetMaxVersion method. I have no idea how to write generic code that does the job.
Could anybody please advice me? Thanks so much!
I'm using LLBL 2.6 and SelfService (and I CAN NOT switch to Adapter anymore ;-)