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;
  • 相关阅读:
    windows脚本设置网络IP地址
    土豆片
    删除iCloud手机备份
    Django——auth用户认证
    分布式文件存储——GlusterFS
    DAS、NAS、SAN
    高可用——数据
    高可用——可用性的度量
    Django——中间件
    高可用——网站架构
  • 原文地址:https://www.cnblogs.com/njcxwz/p/6510823.html
Copyright © 2011-2022 走看看