Is there a generics solution for the following code?
public static int SaveReorder(IList<int> listItems)
{
int result = 0;
int order = 1;
Entity1 db = null;
using (ObjectContext context = new ObjectContext())
{
foreach (int id in listItems)
{
db = Get(context, id);
db.Order = order;
context.SaveChanges();
order += 1;
}
result = 1;
}
return result;
}
listItems contains an ordered sequence of identitykeys. Entity1 is one of the EntityObjects from our EDM. Get(...) is a custom method in the same class to get an EntityObject on basis of the current ObjectContext and by Id.
We want a generic solution for this implementation so we can apply this for several EntityObjects, where the property 'Order' is a common property for all the EntityObjects. Is this possible?