GetMethod does not find public static method if called from ASP .NET MVC controller. (From console application it work OK).
To solve this dummy SaveEntityGenericWrapper
method is used.
How to remove SaveEntityGenericWrapper
from code ?
Why GetMethod("SaveEntityGeneric")
returns null
but GetMethod("SaveEntityGenericWrapper")
works
if called from ASP .NET MVC 2 controller ?
How to make SaveEntityGeneric
private if partial trust is used in MVC2 ?
public class EntityBase() {
public void SaveEntity(EntityBase original)
{
var method = GetType().GetMethod("SaveEntityGenericWrapper");
// why this line returns null if called from ASP .NET MVC 2 controller:
// method = GetType().GetMethod("SaveEntityGeneric");
var gm = method.MakeGenericMethod(GetType());
gm.Invoke(this, new object[] { original, this });
}
// Dummy wrapper reqired for mvc reflection call only.
// How to remove it?
public List<IList> SaveEntityGenericWrapper<TEntity>(TEntity original, TEntity modified)
where TEntity : EntityBase, new()
{
return SaveEntityGeneric<TEntity>(original, modified);
}
public static List<IList> SaveEntityGeneric<TEntity>(TEntity original, TEntity modified)
where TEntity : EntityBase, new()
{ ... actual work is performed here }
}