dapper支持DataSet
在源代码中添加
/// <summary> /// describe:支持 DataSet /// </summary> /// <param name="cnn"></param> /// <param name="adapter"></param> /// <param name="sql"></param> /// <param name="param"></param> /// <param name="buffered"></param> /// <param name="commandTimeout"></param> /// <param name="commandType"></param> /// <returns></returns> public static DataSet ExecuteDataSet(this IDbConnection cnn, IDbDataAdapter adapter, string sql, object param = null, bool buffered = true, int? commandTimeout = null, CommandType? commandType = null) { var ds = new DataSet(); var command = new CommandDefinition(sql, (object)param, null, commandTimeout, commandType, buffered ? CommandFlags.Buffered : CommandFlags.None); var identity = new Identity(command.CommandText, command.CommandType, cnn, null, param == null ? null : param.GetType(), null); var info = GetCacheInfo(identity, param, command.AddToCache); bool wasClosed = cnn.State == ConnectionState.Closed; if (wasClosed) cnn.Open(); adapter.SelectCommand = command.SetupCommand(cnn, info.ParamReader); adapter.Fill(ds); if (wasClosed) cnn.Close(); return ds; }