用于执行存储过程的 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 :
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:
暂无开放 Issues,或尚未同步最近议题。