Entity Framework Core extension to execute stored procedures
Entity Framework Core extension to execute stored procedures
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 :
List rows = null;
ctx.LoadStoredProc("dbo.ListAll")
.AddParam("limit", 300L)
.AddParam("limitOut", out IOutParam limitOut)
.Exec(r => rows = r.ToList());
long limitOutValue = limitOut.Value;
ctx.LoadStoredProc("dbo.ReturnBoolean")
.AddParam("boolean_to_return", true)
.ReturnValue(out IOutParam retParam)
.ExecNonQuery();
bool b = retParam.Value;
ctx.LoadStoredProc("dbo.ListAll")
.AddParam("limit", 1L)
.ExecScalar(out long l);IStoredProcBuilder LoadStoredProc(string name)…Task> ToListAsync();
Task> ToDictionaryAsync(Func keyProjection);
Task>> ToLookupAsync(Func keyProjection);
Task> ToSetAsync();
Task> ColumnAsync();
Task> ColumnAsync(string columnName);
Task FirstAsync();
Task FirstOrDefaultAsync();
Task SingleAsync();
Task SingleOrDefaultAsync();All these methods have a corresponding async method : ToListAsync, ToDictionaryAsync, ...
Install-Package StoredProcedureEFCore
Stored procedure execution was previously not supported in Entity Framework Core:
It is now supported since EF Core 2.1 but this library has few advantages compared to FromSql:
No open issues yet, or sync has not completed.