Servicestack ORMLite/Massive managing multiple DataTables with Expandos / Dynamic?

假如想象 提交于 2019-12-11 00:07:35

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/19428025/servicestack-ormlite-massive-managing-multiple-datatables-with-expandos-dynami

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!