Question

i have a Stored Procedure that returns multiple datatables with dynamic types according to the input and I cannot modify or split it.

I actually retrieve the data in this way:

    var massiveModel = new DynamicModel(dbConn.ConnectionString);
    var connection = new SqlConnection(@"Data Source=127.0.0.1;Initial Catalog=TEST;User ID=as;Password=;Application Name=BRUCE_WAYNE");
        connection.Open();
    var massiveConnection = connection;
    var tmp = massiveModel.Query("exec MY_SP 4412 '20131016' ", MassiveConnection).ToList();

How can I handle those multiple datatables while keeping also the capability to dynamically detect the types for each table's column?

Thx anticipately

Was it helpful?

Solution

I would give dapper dot net a try.

using (var connection = new SqlConnection(@"Data Source=127.0.0.1;Initial Catalog=TEST;User ID=as;Password=;Application Name=BRUCE_WAYNE"))
using (var multi = connection.QueryMultiple("exec MY_SP 4412 '20131016' "))
{
    var resultSetOne = multi.Read().ToList();
    // Do something to determine the type returned...

    var resultSetTwo = multi.Read().ToList();
    // Do something to determine the type returned...
}

I haven't tried this exact scenario but it should give you a hint to start from. For further information refer to the dapper dot net project site.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top