This code add a static method to DbContext named ExecuteStoredProcedure. The latter calls a stored procedure and maps the result into an enumerable of the specified type. If the model type is not specified, it will return a boolean gotten from the SQL Server return statement.
using (var context = new DataAccess.TestContext())
{
IEnumerable<ResultModel> res = context.ExecuteStoredProcedure<ResultModel>("[dbo].[StoredProcedureName]", ("param_name", value));
}
Useful files are:
- DataAccessBase.cs shows how to call a stored procedure
- DbTools.cs contains the method ExecuteStoredProcedure and AutoMap
This repository was made in response of the following Entity Framework's issues :