Support for multiple table result sets.

May 27, 2011 at 5:35 PM

Anyway you can add some support for this?  I use a lot of stored procs that return more then 1 table as a result.  

Great work so far and thanks.

May 30, 2011 at 1:54 PM

Thank you for request.

Okay, I'll support multiple result and ParameterDirection.
I think about such API.

--

// multiple query
var multipleReader = executor.ExecuteMultiple();

var result1 = multipleReader.ExecuteReader(dr => dr); // argument is selector and return type is T[]
var result2 = multipleReader.ExecuteReaderDynamic(dr => dr);
var result3 = multipleReader.ExecuteScalar<T>();
var result4 = multipleReader.Select<T>();
var result5 = multipleReader.SelectDynamic();

// parameter direction
var parameter = new ParameterContainer();
{
    {"p1", 1}, // Input
    {"p2", ParameterDirection.Output, DbType.String, 100},
    {"p3", ParameterDirection.ReturnValue, DbType.Int32}
};   

executor.ExecuteNonQuery("storedproc", parameter);

var r1 = (string)parameter["p1"].Value;
var r2 = (int)parameter["p2"].Value;


---

I want you to teach it if there is some good opinion.

May 30, 2011 at 7:08 PM
Edited May 30, 2011 at 7:11 PM

Looks good, thanks!

Only suggestion i have is to maybe not have to create the ParameterContainer.  Perhaps it could be a property of executor.  Something like: 

executor.ExecuteNonQuery("storedproc", 
    {"p1", 1}, // Input
    {"p2", ParameterDirection.Output, DbType.String, 100},
    {"p3", ParameterDirection.ReturnValue, DbType.Int32}
);

var r1 = (string)executor.Parameter["p1"].Value;
var r2 = (int)executor.Parameter["p2"].Value;