I get objects by
IEnumerable<ObjectStateEntry> om = context.ObjectStateManager.GetObjectStateEntries(System.Data.EntityState.Modified);
How can I get a List of the objects with a type given by a string?
Type typ = Type.GetType("mytype");
var om2 = om.Select(s => s.Entity).OfType<typ>(); // does not work
What you are trying to do cannot be done statically:
varcorresponds to the static type of the expression, while the type of your expression on the right is clearly non-static (it’sIEnumerable<T>, whereTis not known before the runtime).This, however, is legal:
This would produce an
IEnumerable<ObjectStateEntry>.