1

如何获取值读取值行 DataReader 以读取以下代码中 multi 返回的字段值以设置类中的值

OracleRefCursor m_Cursor=null;
Dapper.SqlMapper.GridReader multi =null;

using (m_Conn = new OracleConnection(m_ConnectionString))
{ 
     try
     {
          m_Conn.Open();
          String m_LastName = "S" + "%";
          String m_Id = "";
          String m_EmpId = "";

          var p = new OracleDynamicParameters();

          p.Add(":p_LastName", m_LastName);
          p.Add(":p_Id", m_Id);
          p.Add(":p_EmpId", m_EmpId);                   
          p.Add( ":p_Cursor1", dbType: OracleDbType.RefCursor, direction: ParameterDirection.Output );


          using (multi = m_Conn.QueryMultiple(m_ProcedureName, param: p, commandType: CommandType.StoredProcedure))
          {                           

          }
    }
    catch (Exception ex)
    {
           String m_Error = ex.ToString();
    }

}//end of using statement
4

1 回答 1

0

来自 Dapper文档

var sql = 
@"
select * from Customers where CustomerId = @id
select * from Orders where CustomerId = @id
select * from Returns where CustomerId = @id";

using (var multi = connection.QueryMultiple(sql, new {id=selectedId}))
{
   var customer = multi.Read<Customer>().Single();
   var orders = multi.Read<Order>().ToList();
   var returns = multi.Read<Return>().ToList();
   ...
} 
于 2013-06-04T16:52:54.313 回答