如何在具有样板结构的asp.net核心中使用存储过程? [英] How to use Stored Procedure in asp.net core with boilerplate architecture?
问题描述
我正在使用带有abp(Asp.net BoilerPlate)框架的asp.net核心应用程序.我想使用存储过程获取数据,并在此代码优先体系结构中实现CRUD操作.最好的方法是什么?
I am using asp.net core application with abp(Asp.net BoilerPlate) framework. I want to use stored procedure to get the data and also to implement CRUD operations in this code first architecture. What will be best way to do so?
预先感谢
推荐答案
以下是将参数发送到存储过程以删除用户的示例:
Here is an example that sends a parameter to a stored procedure to delete a user:
public async Task DeleteUser(EntityDto input)
{
await Context.Database.ExecuteSqlCommandAsync(
"EXEC DeleteUserById @id",
default(CancellationToken),
new SqlParameter("id", input.Id)
);
}
请参阅:使用存储过程,用户定义的功能和带有ASP.NET Boilerplate的自定义存储库中的视图
源代码在Github上发布: https://github.com/aspnetboilerplate/aspnetboilerplate-samples/tree/master/StoredProcedureDemo
Source code is published on Github: https://github.com/aspnetboilerplate/aspnetboilerplate-samples/tree/master/StoredProcedureDemo
这篇关于如何在具有样板结构的asp.net核心中使用存储过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!