MVC c# 调用sql的存储过程

var hid = new SqlParameter { ParameterName = "HistoryId", Value = history.Id, Direction = ParameterDirection.Input };
var sid = new SqlParameter { ParameterName = "StoreId", Value = StoreId, Direction = ParameterDirection.Input };
var qrcode = new SqlParameter { ParameterName = "QRCode", Value = strQRCode, Direction = ParameterDirection.Input };
var guidcode = new SqlParameter { ParameterName = "GUIDCode", Value = strGUIDCode, Direction = ParameterDirection.Input };
var result = new SqlParameter { ParameterName = "Result", Value = 0, Direction = ParameterDirection.Output };
db.Database.ExecuteSqlCommand("exec @Result = OptStock @HistoryId,@StoreId,@QRCode,@GUIDCode", hid, sid, qrcode, guidcode, result);


model.Status = (int)result.Value;

存储过程为OptStock,带参数输入,输出

原文地址:https://www.cnblogs.com/Zatsugaku-code/p/5761014.html