verdie-g/StoredProcedureEFCore

How to include multiple parameters?

Closed this issue · 2 comments

This works great with only one parameter, but I can't figure out how to include more than one to work with the DbTool.cs

ExecuteStoredProcedure takes a variable number of arguments:

public static List<T> ExecuteStoredProcedure<T>(this DbContext context, string name, params StoredProcedureParameter[] parameters)

You can pass as many arguments a you want:

context.ExecuteStoredProcedure<ResultModel>("[dbo].[StoredProcedureName]",
        new StoredProcedureParameter("param_name", value),
        new StoredProcedureParameter("param_name2", value2),
        new StoredProcedureParameter("param_name3", value3)
);

I replaced StoredProcedureParameter by tuples in my last commit, so it's less verbose.

You can pass parameters like that now :

context.ExecuteStoredProcedure<ResultModel>("[dbo].[StoredProcedureName]",
        ("param_name", value),
        ("param_name2", value2),
        ("param_name3", value3)
);