EF框架下调用 调用Oracle 存储过程

前端之家收集整理的这篇文章主要介绍了EF框架下调用 调用Oracle 存储过程前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
public object ExecuteByProc(string procName,params DbParameter[] dbParameter)
        {
                    //OracleParameter[] Oparms = new OracleParameter[dbParameter.Length];
                    //int pCount = dbParameter.Length;
                    //int j = 0;
                    //foreach (DbParameter item in dbParameter)
                    //{
                    //    if (j < pCount - 1)
                    //        Oparms[j] = new OracleParameter(item.ParameterName,item.Value);
                    //    j++;
                    //}

                    
                    //var oParam = new OracleParameter(dbParameter[pCount - 1].ParameterName,OracleDbType.Int32,10);
                    //oParam.Direction = System.Data.ParameterDirection.Output;
                    //oParam.Value = 0;
                    //Oparms[j - 1] = oParam;
                    
                    var cmd = dbcontext.Database.Connection.CreateCommand();
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = procName;
                    if (dbParameter.Length > 0)
                        cmd.Parameters.AddRange(dbParameter);
                    // cmd.Parameters.AddRange(Oparms);
                    cmd.Connection.Open();
                   int retCode= cmd.ExecuteNonQuery();
                   var oParam = dbParameter[dbParameter.Length - 1];

                    cmd.Connection.Close();

                    return oParam.Value;// Convert.ToInt32(oParam.Value.ToString());//最后一个参数为输出参数

                //return dbcontext.Database.ExecutesqlCommand(DbContextExtensions.BuilderProc(procName,dbParameter),dbParameter);
   
}
原文链接:https://www.f2er.com/oracle/209667.html

猜你在找的Oracle相关文章