コード例 #1
0
        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));
        }
コード例 #2
0
 public static void WriteToServer(SqlConnection connection, MssqlCommandBulkCopyDataSet dataset)
 {
     (new MssqlCommandBulkCopy(connection, dataset)).BulkCopy();
 }
コード例 #3
0
 private MssqlCommandBulkCopy(SqlConnection connection, MssqlCommandBulkCopyDataSet dataset) : this(connection, new[] { dataset })
 {
 }