StoredProcedureEFCore 0.2.0

Entity Framework Core extension to execute a stored procedure and map the result

There is a newer version of this package available.
See the version list below for details.
Install-Package StoredProcedureEFCore -Version 0.2.0
dotnet add package StoredProcedureEFCore --version 0.2.0
<PackageReference Include="StoredProcedureEFCore" Version="0.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StoredProcedureEFCore --version 0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: StoredProcedureEFCore, 0.2.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install StoredProcedureEFCore as a Cake Addin
#addin nuget:?package=StoredProcedureEFCore&version=0.2.0

// Install StoredProcedureEFCore as a Cake Tool
#tool nuget:?package=StoredProcedureEFCore&version=0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Execute stored procedures with Entity Framework Core

DbContext extension with LoadStoredProc method which creates
an IStoredProcBuilder.

The method handles :

  • Extra column in result set
  • Extra property in model
  • Null values in result set
  • Underscores or hypens in result set column names ("column_name" is mapped to ColumnName property)
  • Int (db) to enumeration (result model) mapping

Example

List<Model> rows = null;

ctx.LoadStoredProc("dbo.ListAll")
   .AddParam<T>("limit", 300L)
   .AddParam<T>("limitOut", out IOutParam<long> limitOut)
   .Exec(r => rows = r.ToList<Model>());

long limitOutValue = limitOut.Value;

ctx.LoadStoredProc("dbo.ReturnBoolean")
   .AddParam<T>("boolean_to_return", true)
   .ReturnValue(out IOutParam<bool> retParam)
   .ExecNonQuery();

bool b = retParam.Value;

ctx.LoadStoredProc("dbo.ListAll")
   .AddParam<T>("limit", 1L)
   .ExecScalar(out long l);

API

DbContext

IStoredProcBuilder             LoadStoredProc(string name)

IDataReader

List<T>                        ToList<T>()
Dictionary<TKey, TValue>       ToDictionary<TKey, TValue>()
Dictionary<TKey, List<TValue>> ToLookup<TKey, TValue>()
HashSet<T>                     ToSet<T>()
List<T>                        Column<T>()
T                              First<T>()
T                              FirstOrDefault<T>()
T                              Single<T>()
T                              SingleOrDefault<T>()

IStoredProcBuilder

IStoredProcBuilder             AddParam<T>(string name, T val)                             // Input parameter
IStoredProcBuilder             AddParam<T>(string name, T val, out OutParam<T> outParam)   // Ouput parameter
IStoredProcBuilder             AddParam<T>(string name, out IOutParam<T> outParam)         // Input/Ouput parameter
IStoredProcBuilder             ReturnValue<T>(out IOutParam<T> retParam)
void                           Exec(Action<IDataReader> action)
void                           ExecNonQuery()
void                           ExecScalar<T>(out T val)

Installation

Install-Package StoredProcedureEFCore

Why ?

Stored procedure execution is not supported in entity framework core:

Execute stored procedures with Entity Framework Core

DbContext extension with LoadStoredProc method which creates
an IStoredProcBuilder.

The method handles :

  • Extra column in result set
  • Extra property in model
  • Null values in result set
  • Underscores or hypens in result set column names ("column_name" is mapped to ColumnName property)
  • Int (db) to enumeration (result model) mapping

Example

List<Model> rows = null;

ctx.LoadStoredProc("dbo.ListAll")
   .AddParam<T>("limit", 300L)
   .AddParam<T>("limitOut", out IOutParam<long> limitOut)
   .Exec(r => rows = r.ToList<Model>());

long limitOutValue = limitOut.Value;

ctx.LoadStoredProc("dbo.ReturnBoolean")
   .AddParam<T>("boolean_to_return", true)
   .ReturnValue(out IOutParam<bool> retParam)
   .ExecNonQuery();

bool b = retParam.Value;

ctx.LoadStoredProc("dbo.ListAll")
   .AddParam<T>("limit", 1L)
   .ExecScalar(out long l);

API

DbContext

IStoredProcBuilder             LoadStoredProc(string name)

IDataReader

List<T>                        ToList<T>()
Dictionary<TKey, TValue>       ToDictionary<TKey, TValue>()
Dictionary<TKey, List<TValue>> ToLookup<TKey, TValue>()
HashSet<T>                     ToSet<T>()
List<T>                        Column<T>()
T                              First<T>()
T                              FirstOrDefault<T>()
T                              Single<T>()
T                              SingleOrDefault<T>()

IStoredProcBuilder

IStoredProcBuilder             AddParam<T>(string name, T val)                             // Input parameter
IStoredProcBuilder             AddParam<T>(string name, T val, out OutParam<T> outParam)   // Ouput parameter
IStoredProcBuilder             AddParam<T>(string name, out IOutParam<T> outParam)         // Input/Ouput parameter
IStoredProcBuilder             ReturnValue<T>(out IOutParam<T> retParam)
void                           Exec(Action<IDataReader> action)
void                           ExecNonQuery()
void                           ExecScalar<T>(out T val)

Installation

Install-Package StoredProcedureEFCore

Why ?

Stored procedure execution is not supported in entity framework core:

NuGet packages (1)

Showing the top 1 NuGet packages that depend on StoredProcedureEFCore:

Package Downloads
DevDiamond.AspNetCore.JqueryDataTable
Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.5 14,878 11/15/2020
1.0.4 34,293 6/16/2020
1.0.3 207 6/15/2020
1.0.2 8,201 4/10/2020
1.0.1 9,305 2/13/2020
1.0.0 2,655 1/14/2020
0.3.15 8,047 10/30/2019
0.3.14 776 10/22/2019
0.3.13 357 10/17/2019
0.3.12 431 8/9/2019
0.3.11 11,862 6/1/2019
0.3.10 14,946 11/15/2018
0.3.9 7,137 5/4/2018
0.3.8 957 4/21/2018
0.3.7 824 4/3/2018
0.3.6 832 3/16/2018
0.3.5 617 3/16/2018
0.3.4 845 3/2/2018
0.3.3 905 2/1/2018
0.3.2 710 1/19/2018
0.3.1 640 1/8/2018
0.3.0 627 1/8/2018
0.2.0 713 12/29/2017
0.1.1 675 12/28/2017
0.1.0 570 12/26/2017
Show less