zoukankan      html  css  js  c++  java
  • IBatisNet中返回DataTable的实现

    //返回IDbCommand的函数
    private IDbCommand GetDbCommand(string statementName,object parameterObject)
      {
       IDbCommand p_command;
       IBatisNet.Common.IDalSession m_sqlSession;

       SqlMapper sqlMap = GetLocalSqlMap();
       if (sqlMap.LocalSession != null)
       {
        m_sqlSession = sqlMap.LocalSession;
       }
       else
       {
        m_sqlSession = sqlMap.OpenConnection();
       }
        IMappedStatement mappedStatement = GetLocalSqlMap().GetMappedStatement(statementName);
        RequestScope requestScope = mappedStatement.Statement.Sql.GetRequestScope(parameterObject, m_sqlSession);
       // 通过这个方法生成一个DbCommand,并且给所有的SQL参数指定值。如果没有调用此方法,requestScope.IDbCommand属性为空  //
       mappedStatement.PreparedCommand.Create(requestScope,
        m_sqlSession, mappedStatement.Statement, parameterObject);
       p_command = requestScope.IDbCommand;
       return p_command;
      }
    //实现返回DataSet的函数
    protected DataSet ExecuteQueryTable(string statementName,object parameterObject)
      {
       DataSet ds = new DataSet();
       SqlMapper sqlMap = GetLocalSqlMap();
       IDbCommand cmd = GetDbCommand(statementName,parameterObject);
       cmd.CommandType = CommandType.Text;
       cmd.CommandText = this.GetSql(statementName,parameterObject);
       if (sqlMap.LocalSession != null)
       {
        IDbDataAdapter adapter =
         sqlMap.LocalSession.CreateDataAdapter(cmd);
        adapter.Fill(ds);
        return ds;
       }
       else
       {
        IDalSession session = sqlMap.OpenConnection();
        IDbDataAdapter adapter =
         session.CreateDataAdapter(cmd);
        adapter.Fill(ds);
        session.CloseConnection();
        return ds;
       }
      }

  • 相关阅读:
    七类网线 支持10gb/s的速度的计算方法
    Linux 压缩 解压缩 命令相关
    [至顶网] Win2019 发布 LTSC 10年支持期
    安装报错信息 改天找人帮忙看下.
    [学习]仿照cnblog 搭建 Oracle RAC 双节点 困.. 后续做不下去了..
    Windows 作为 openssl server端时的处理
    阿里云构建Kafka单机集群环境
    nginx解决跨域
    让网站永久拥有HTTPS
    ORA-01940: cannot drop a user that is currently connected 问题解析
  • 原文地址:https://www.cnblogs.com/jacktu/p/404441.html
Copyright © 2011-2022 走看看