var dataSet = _testRepository.SqlDataSetQuery(@"
select * from A;
select * from B;
select * from C;
", params);
var dataSet = _testRepository.SqlProcedureDataSetQuery("存储过程名", new PROCModel{});
将 DataSet
转换成 List 对象(推荐)
// 纯 sql 方式
var data1 = _testRepository.SqlDataSetQuery<T1>(@"sqls...", params);
var (data1, data2) = _testRepository.SqlDataSetQuery<T1, T2>(@"sqls...", params);
var (data1, data2, data3) = _testRepository.SqlDataSetQuery<T1, T2, T3>(@"sqls...", params);
var (data1, data2, data3, data4) = _testRepository.SqlDataSetQuery<T1, T2, T3, T4>(@"sqls...", params);
var (data1, data2, data3, data4, data5) = _testRepository.SqlDataSetQuery<T1, T2, T3, T4, T5>(@"sqls...", params);
var (data1, data2, data3, data4, data5, data6) = _testRepository.SqlDataSetQuery<T1, T2, T3, T4, T5, T6>(@"sqls...", params);
var (data1, data2, data3, data4, data5, data6, data7) = _testRepository.SqlDataSetQuery<T1, T2, T3, T4, T5, T6, T7>(@"sqls...", params);
var (data1, data2, data3, data4, data5, data6, data7, data8) = _testRepository.SqlDataSetQuery<T1, T2, T3, T4, T5, T6, T7, T8>(@"sqls...", params);
// 存储过程方式
var data1 = _testRepository.SqlProcedureDataSetQuery<T1>("存储过程名", new PROCModel{});
var (data1, data2) = _testRepository.SqlProcedureDataSetQuery<T1, T2>("存储过程名", new PROCModel{});
var (data1, data2, data3) = _testRepository.SqlProcedureDataSetQuery<T1, T2, T3>("存储过程名", new PROCModel{});
var (data1, data2, data3, data4) = _testRepository.SqlProcedureDataSetQuery<T1, T2, T3, T4>("存储过程名", new PROCModel{});
var (data1, data2, data3, data4, data5) = _testRepository.SqlProcedureDataSetQuery<T1, T2, T3, T4, T5>("存储过程名", new PROCModel{});
var (data1, data2, data3, data4, data5, data6) = _testRepository.SqlProcedureDataSetQuery<T1, T2, T3, T4, T5, T6>("存储过程名", new PROCModel{});
var (data1, data2, data3, data4, data5, data6, data7) = _testRepository.SqlProcedureDataSetQuery<T1, T2, T3, T4, T5, T6, T7>("存储过程名", new PROCModel{});
var (data1, data2, data3, data4, data5, data6, data7, data8) = _testRepository.SqlProcedureDataSetQuery<T1, T2, T3, T4, T5, T6, T7, T8>("存储过程名", new PROCModel{});
纯 sql
查询并返回 DataTable
(不推荐)
var dataTable = _testRepository.SqlQuery(@"select * from A", params);
var dataTable = _testRepository.SqlProcedureQuery("存储过程名", new PROCModel{});
var list = _testRepository.SqlQuery<A>(@"select * from A", params);
// 支持匿名类
var procModel = new { Name = "Monk", Age = 27 };
var sqlParameters = procModel.ToSqlParameters();
// 支持强类型
var procModel = new PROCModel{ Name = "Monk", Age = 27 };
var sqlParameters = procModel.ToSqlParameters();