.NET 4.5 introduces a few new attributes that give you this kind of information.
The CallerMethodNameAttribute
:
Allows you to obtain the method or property name of the caller to the method.
public OperationStat Update(object obj, [CallerMethodName] string calledFrom = "")
{
OperationStat op = new OperationStat();
string callmethod = "Add";
if(calledFrom != callmethod)
{
op.Primarykey = pkey.newkey();
}
return op;
}