I'm trying to work with two contexts in a generic repository and I should invoke the static method GetObjectContext()
with dynamic type like ObjectContextManager<DynamicType>.GetObjectContext()
.
private DataContext GetDataContext()
{
Type type = GetContainerType();
Type paoloGenericClassType = typeof(ObjectContextManager<>).MakeGenericType(type);
MethodInfo method = paoloGenericClassType.GetMethod("GetObjectContext", BindingFlags.Static);
return method.Invoke(null, BindingFlags.Static, null, null, null) as DataContext;
}
I'm try different variants, but it doesn't work. How can I do this?