zoukankan      html  css  js  c++  java
  • EF CODEFIRST WITH ORACLE 存储过程

    EF  CODEFIRST WITH ORACLE

    解决存储过程一直没找到解决方案

    所以最后也没办法还是用了最基本的解决方案

    采用Oracle.ManagedDataAccess提供的ADO基础访问类,不需要再次额外引用第三方类库了。

    using Oracle.ManagedDataAccess.Client;

    public 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;
  • 相关阅读:
    「SOL」工厂选址(BZOJ)
    「NOTE」数论小札
    Flask实现简单的群聊和单聊
    python基础总结
    基于Flask和百度AI实现与机器人对话
    django创建路径导航
    django中权限控制到按钮级别
    django中非菜单权限的归属
    MongoDB的增删改查
    jQuery于js的区别和联系
  • 原文地址:https://www.cnblogs.com/njcxwz/p/6510823.html
Copyright © 2011-2022 走看看