Using DataReader in Dapper with Oracle

dapper

Question

How do I get values read values line a DataReader to read values of fields returned by multi in the following code to set the values in the Class

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

Popular Answer

From Dapper docs:

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();
   ...
} 


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why