DatabaseExtensionsGetMethodInfo Method

Get the method information for the calling method in the given data context type for use in a stored procedure method call.

Definition

Namespace: EWSoftware.EntityFramework
Assembly: EWSoftware.EntityFramework (in EWSoftware.EntityFramework.dll) Version: 2025.11.12.0
public static MethodInfo GetMethodInfo(
	this DbContext dataContext
)

Parameters

dataContext  DbContext
The data context

Return Value

MethodInfo
The method information for the calling method in the given data context

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DbContext. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

When a stored procedure method is called asynchronously, the method information must be obtained from a stack trace as the call may be inside the compiler generated state machine. This extension method can be used to obtain the necessary method information whether the stored procedure method is called synchronously or asynchronously.

Example

C#
[MethodStoredProcedure("spStateCodeAddUpdate")]
public int AddOrUpdateStateCode(string? oldState, string? state, string? stateDesc)
{
    return this.ExecuteMethodNonQuery(this.GetMethodInfo(), oldState, state, stateDesc).ReturnValue;
}

Exceptions

InvalidOperationExceptionThis is thrown if the method information cannot be determined.

See Also