GetCached(BLCustomer.GetAll, "GetAll");
where "GetAll" is session key.
How can I do something like this?
GetCached(BLCustomer.GetAll, BLCustomer.GetAll.ToString());
UPDATE:
other worlds I wanna to get the string "GetAll" (not names of customers, but the name of the method) from method name BLCustomer.GetAll().
I want to use something like this
GetCached(BLCustomer.GetSingle, BLCustomer.GetSingle.ToString());
instead of
GetCached(BLCustomer.GetSingle, "GetSingle");
to avoid hardcoding name of methods.
Change GetCached like this:
ReturnType GetCached(SomeFunc f)
{
var methodname = f.Method.Name;
// add rest of code
}
Assumptions:
I guess GetCached actually looks like this currently:
T GetCached<T>(Func<T> accessor, string name)
{
...
}
Given the accessor is already a delegate, the name can be determined as shown above.
If not, my suggestion will not work.
The above also assumes that BLCustomer.GetSingle is a method (instance or static should be ok).
The call would then be:
var r = GetCached(BLCustomer.GetSingle); // delegate implicitly created
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With