this is what I do if I know the type;
TypeA.Get<TypeA>(Id).Delete();
and what I am trying to do is this;
object ObjectA;
(BaseEntity<typeof(ObjectA)>).Get<(BaseEntity<typeof(ObjectA)>)>(Id).Delete();
which didn't work, any idea how to do this properly?
You can either:
Get
and Delete
methods, or:Get
and dynamic
to invoke Delete
Since you're giving up static typing either way, I'd go with the 2nd option for simplicity.
var typeA = objectA.GetType();
var fEntityType = typeof(FEntity<>).MakeGenericType(typeA);
var getMethod = fEntityType.GetMethod("Get").MakeGenericMethod(typeA);
dynamic result = getMethod.Invoke(null, new object[]{ Id });
result.Delete();
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments