StoredProcedureEFCore 0.3.2
.NET Standard 1.3
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package StoredProcedureEFCore --version 0.3.2
NuGet\Install-Package StoredProcedureEFCore -Version 0.3.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="StoredProcedureEFCore" Version="0.3.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StoredProcedureEFCore --version 0.3.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: StoredProcedureEFCore, 0.3.2"
#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.3.2
// Install StoredProcedureEFCore as a Cake Tool
#tool nuget:?package=StoredProcedureEFCore&version=0.3.2
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 to build a stored procedure with a custom mapping strategy using the provided DbDataReader extension.
The method handles :
- Extra column in result set
- Extra property in model
- Null values in result set
- Underscores 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("limit", 300L)
.AddParam("limitOut", out IOutParam<long> limitOut)
.Exec(r => rows = r.ToList<Model>());
long limitOutValue = limitOut.Value;
ctx.LoadStoredProc("dbo.ReturnBoolean")
.AddParam("boolean_to_return", true)
.ReturnValue(out IOutParam<bool> retParam)
.ExecNonQuery();
bool b = retParam.Value;
ctx.LoadStoredProc("dbo.ListAll")
.AddParam("limit", 1L)
.ExecScalar(out long l);
API
DbContext
IStoredProcBuilder LoadStoredProc(string name)
DbDataReader
List<T> ToList<T>()
Task<List<T>> ToListAsync<T>()
Dictionary<TKey, TValue> ToDictionary<TKey, TValue>()
Task<Dictionary<TKey, TValue>> ToDictionaryAsync<TKey, TValue>()
Dictionary<TKey, List<TValue>> ToLookup<TKey, TValue>()
Task<Dictionary<TKey, List<TValue>>> ToLookupAsync<TKey, TValue>()
HashSet<T> ToSet<T>()
Task<HashSet<T>> ToSetAsync<T>()
List<T> Column<T>()
List<T> Column<T>(string columnName)
Task<List<T>> ColumnAsync<T>()
Task<List<T>> ColumnAsync<T>(string columnName)
T First<T>()
Task<T> FirstAsync<T>()
T FirstOrDefault<T>()
Task<T> FirstOrDefaultAsync<T>()
T Single<T>()
Task<T> SingleAsync<T>()
T SingleOrDefault<T>()
Task<T> SingleOrDefaultAsync<T>()
IStoredProcBuilder
IStoredProcBuilder AddParam<T>(string name, T val) // Input parameter
IStoredProcBuilder AddParam<T>(string name, T val, out OutParam<T> outParam) // Input/Ouput parameter
IStoredProcBuilder AddParam<T>(string name, out IOutParam<T> outParam) // Ouput parameter
IStoredProcBuilder ReturnValue<T>(out IOutParam<T> retParam)
void Exec(Action<DbDataReader> action)
Task ExecAsync(Func<DbDataReader, Task> action)
void ExecNonQuery()
Task ExecNonQueryAsync()
void ExecScalar<T>(out T val)
Task ExecScalarAsync<T>(Action<T> action)
Installation
Install-Package StoredProcedureEFCore
Why ?
Stored procedure execution is not supported in entity framework core:
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows |
.NET Core | netcoreapp1.0 netcoreapp1.1 netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1 |
.NET Standard | netstandard1.3 netstandard1.4 netstandard1.5 netstandard1.6 netstandard2.0 netstandard2.1 |
.NET Framework | net46 net461 net462 net463 net47 net471 net472 net48 |
MonoAndroid | monoandroid |
MonoMac | monomac |
MonoTouch | monotouch |
Tizen | tizen30 tizen40 tizen60 |
Universal Windows Platform | uap uap10.0 |
Xamarin.iOS | xamarinios |
Xamarin.Mac | xamarinmac |
Xamarin.TVOS | xamarintvos |
Xamarin.WatchOS | xamarinwatchos |
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 1.3
- Microsoft.EntityFrameworkCore.Design (>= 1.0.1)
- NETStandard.Library (>= 1.6.1)
- System.Data.Common (>= 4.3.0)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on StoredProcedureEFCore:
Package | Downloads |
---|---|
BinaryBlox.SDK
Package Description |
|
BinaryBlox.SDK.Configuration
Package Description |
|
BinaryBlox.SDK.Account
Package Description |
|
BinaryBlox.SDK.Permission
Package Description |
|
DevDiamond.AspNetCore.JqueryDataTable
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
1.0.5 | 164,312 | 11/15/2020 | |
1.0.4 | 62,348 | 6/16/2020 | |
1.0.3 | 421 | 6/15/2020 | |
1.0.2 | 9,940 | 4/10/2020 | |
1.0.1 | 12,586 | 2/13/2020 | |
1.0.0 | 3,483 | 1/14/2020 | |
0.3.15 | 13,186 | 10/30/2019 | |
0.3.14 | 2,289 | 10/22/2019 | |
0.3.13 | 563 | 10/17/2019 | |
0.3.12 | 808 | 8/9/2019 | |
0.3.11 | 14,661 | 6/1/2019 | |
0.3.10 | 18,674 | 11/15/2018 | |
0.3.9 | 8,508 | 5/4/2018 | |
0.3.8 | 1,338 | 4/21/2018 | |
0.3.7 | 1,195 | 4/3/2018 | |
0.3.6 | 1,227 | 3/16/2018 | |
0.3.5 | 991 | 3/16/2018 | |
0.3.4 | 1,236 | 3/2/2018 | |
0.3.3 | 1,319 | 2/1/2018 | |
0.3.2 | 1,105 | 1/19/2018 | |
0.3.1 | 1,079 | 1/8/2018 | |
0.3.0 | 1,080 | 1/8/2018 | |
0.2.0 | 1,177 | 12/29/2017 | |
0.1.1 | 1,165 | 12/28/2017 | |
0.1.0 | 1,010 | 12/26/2017 |