private T GetResult(SqlDataReader reader) { var type = typeof(T); if (type == typeof(DataSet) || type == typeof(DataTable) || type == typeof(MssqlCommandBulkCopyDataSet)) { var ds = new DataSet { EnforceConstraints = false }; while (!reader.IsClosed) { ds.Tables.Add().Load(reader); } object result = ds; if (type == typeof(DataTable)) { result = ds.Tables.Count > 0 ? ds.Tables[0] : new DataTable(); } if (type == typeof(MssqlCommandBulkCopyDataSet)) { result = new MssqlCommandBulkCopyDataSet(FieldSizer.FieldSizerOf(ds), ds); } return((T)result); } return(EntityWriter.To <T>(reader)); }
public static void WriteToServer(SqlConnection connection, MssqlCommandBulkCopyDataSet dataset) { (new MssqlCommandBulkCopy(connection, dataset)).BulkCopy(); }
private MssqlCommandBulkCopy(SqlConnection connection, MssqlCommandBulkCopyDataSet dataset) : this(connection, new[] { dataset }) { }