I found a similar question here How can I find the method that called the current method? but answers in this question also give same result as I have mentioned in my first example
Here is method that I am using
public class iStore
{
public T GetSiteCacheValueByFunc<T>(Func<T> func) where T : class
{
var methodName = func.Method.Name;
}
}
Here I am using iStore.GetSiteCacheValueByFunc
by using following code I get methodName <Index>b_2
while I should get GetAllLanguages
public ActionResult Index()
{
var site = BusinessLogic.Caching.iStore;
var languages = site.GetSiteCacheValueByFunc<IEnumerable<Language>>(() => LanguageManager.GetAllLanguages());
}
If I use following code I get correct methodName GetAllLanguages
but in this way I am not able to pass parameters to GetAllLanguages method
public ActionResult Index()
{
var site = BusinessLogic.Caching.iStore;
var languages = site.GetSiteCacheValueByFunc<IEnumerable<Language>>(LanguageManager.GetAllLanguages);
}
Where I am doing wrong? and how can I get correct methodName?