如何在具有样板结构的asp.net核心中使用存储过程? [英] How to use Stored Procedure in asp.net core with boilerplate architecture?

查看:104
本文介绍了如何在具有样板结构的asp.net核心中使用存储过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆