I have throughout my application many methods where I load collections. They all (actually most with a couple of differentials) follow the following pattern:
public BaseCollection<ObjectType1> LoadObjectType1(EventHandler handleEvent)
{
var myQuery = ObjectType1.Load(MyServiceContext);
return new DataManager<ObjectType1>().GetData(myQuery , handleEvent, MyServiceContextt);
}
public BaseCollection<ObjectType2> LoadObjectType2(EventHandler handleEvent)
{
var myQuery = ObjectType2.Load(MyServiceContext);
return new DataManager<ObjectType2>().GetData(myQuery , handleEvent, MyServiceContextt);
}
public BaseCollection<ObjectType3> LoadObjectType3(EventHandler handleEvent)
{
var query = ObjectType3.Load(MyServiceContext);
return new DataManager<ObjectType3>().GetData(query, handleEvent, MyServiceContextt);
}
Where ObjectType# are my business objects, e.g. Employee, Department, etc.
I would like to convert these to harness Generics.
Any advice will be greatly appreciated.