EF CODEFIRST WITH ORACLE 存储过程
时间:2021-07-01 10:21:17
帮助过:14人阅读
object[] ExecuteProc(
string procName,
params DbParameter[] parms)
{
MyDbContext dbContext =
this.GetDbContext(AccessMode.Write);
using (
var conn =
new OracleConnection(dbContext.Database.Connection.ConnectionString))
{
List<DbParameter> outParms = parms.Where(p => p.Direction == System.Data.ParameterDirection.Output || p.Direction ==
System.Data.ParameterDirection.ReturnValue).ToList();
OracleCommand command =
new OracleCommand(procName);
command.Connection =
conn;
command.CommandType =
CommandType.StoredProcedure;
command.Parameters.AddRange(parms);
conn.Open();
command.ExecuteNonQuery();
command.Parameters.Clear();
command.Dispose();
conn.Close();
object[] values = outParms.Select(r =>
r.Value).ToArray();
return values;
}
}
调用
BaseRepository resp = new BaseRepository();
var p3 = resp.GetParameterOut("COUNT_ROW", System.Data.DbType.Int32, 4);
object[] o = resp.ExecuteProc("PROC1", p3);
var ss = p3.Value;
EF CODEFIRST WITH ORACLE 存储过程
标签:方案 class data 需要 out return command codefirst val