MethodStoredProcedureAttribute Class

This attribute is used to specify the stored procedure executed by a method on a data context

Definition

Namespace: EWSoftware.EntityFramework.DataAnnotations
Assembly: EWSoftware.EntityFramework (in EWSoftware.EntityFramework.dll) Version: 2025.11.12.0
public sealed class MethodStoredProcedureAttribute : StoredProcedureAttribute
Inheritance
Object    Attribute    StoredProcedureAttribute    MethodStoredProcedureAttribute

Remarks

This attribute is optional. If not specified on a data context stored procedure method, the name of the stored procedure is assumed to be the same as the data context method's name. If the method name ends with the value of the AsyncMethodSuffix property, the suffix will be removed from the method name to obtain the stored procedure name.

Example

C#
// Use the attribute to specify the stored procedure name when it differs from the method name
[MethodStoredProcedure("spStateCodeAddUpdate")]
public int AddOrUpdateStateCode(string? oldState, string? state, string? stateDesc)
{
    return this.ExecuteMethodNonQuery(this.GetMethodInfo(), oldState, state, stateDesc).ReturnValue;
}

[MethodStoredProcedure("spStateCodeDelete")]
public int DeleteStateCode(string? state)
{
    return this.ExecuteMethodNonQuery(this.GetMethodInfo(), state).ReturnValue;
}

[MethodStoredProcedure("spProductSearch")]
public IEnumerable<ProductSearchResult> SearchForProducts(string? productName, string? categoryName,
    string? companyName)
{
    return this.ExecuteMethodQuery<ProductSearchResult>(this.GetMethodInfo(),
        productName, categoryName, companyName);
}

Constructors

MethodStoredProcedureAttribute Initialize a new instance of the attribute using the given stored procedure name

Properties

ParameterNamePrefix This can be used to define an optional parameter name prefix that will be applied to all stored procedure parameters.
(Inherited from StoredProcedureAttribute)
StoredProcedureName This read-only property returns the name of the stored procedure to execute when loading entities
(Inherited from StoredProcedureAttribute)
TypeIdWhen implemented in a derived class, gets a unique identifier for this Attribute.
(Inherited from Attribute)

Methods

EqualsReturns a value that indicates whether this instance is equal to a specified object.
(Inherited from Attribute)
GetHashCodeReturns the hash code for this instance.
(Inherited from Attribute)
GetTypeGets the Type of the current instance.
(Inherited from Object)
IsDefaultAttributeWhen overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.
(Inherited from Attribute)
MatchWhen overridden in a derived class, returns a value that indicates whether this instance equals a specified object.
(Inherited from Attribute)
ToStringReturns a string that represents the current object.
(Inherited from Object)

Extension Methods

ToNullableT This is used to convert objects to null values if they are equal to null, DBNull.Value, or the default value for the given type.
(Defined by DatabaseExtensions)
ToStringOrNull This is used to convert an object to a string and return either the string value if not empty, or null if it is an empty string.
(Defined by DatabaseExtensions)

See Also