I have a method with this signature:
public void GenerateLog<TEntity>(TEntity entity) where TEntity : EntityObject
How can I loop through my ObjectContext and call this for each Entity in my ObjectContext?
I know that I can do this:
foreach (ObjectStateEntry entry in
context.ObjectStateManager.GetObjectStateEntries(
EntityState.Added | EntityState.Modified))
{
string entityName = entry.Entity.GetType().Name;
}
But I don’t know how to go from a String representation of the name to GenerateLog<MYSTRING> instead of GenerateLog<TEntity>.
You need to make a generic method from your
GenerateLogand then call that. I normally need to mess around a bit before I get something like this to work, but this should be closeYourClassis simply the class the GenerateLog is in.