'How to call update stored procedure from .NET Core Entity Framework
This is my stored procedure:
CREATE PROCEDURE [dbo].[Admin_SetUserToIsDeleted]
(@bb_customer_id int)
AS
DECLARE @bb_customer_id_local INT
SET @bb_customer_id_local = @bb_customer_id
BEGIN TRAN
UPDATE dbo.bb_customer_login_identification WITH (rowlock)
SET is_deleted = 1
WHERE bb_customer_id = @bb_customer_id_local
UPDATE dbo.bb_customer
SET is_deleted = 1
WHERE bb_customer_id = @bb_customer_id_local
COMMIT TRAN
Solution 1:[1]
public object ExecuteAdminUserDeleted(int CustomerID)
{
var CustParam = new SqlParameter("@bb_customer_id", CustomerID);
_dbContext.Database.ExecuteSqlCommand("Admin_SetUserToIsDeleted @bb_customer_id=@bb_customer_id", CustParam);
}
If you're returning data from the stored procedure, you have to call it differently (FromSqlRaw) and scaffold a database class to hold the returned data.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | nonesuch |
