Пример #1
0
        public static long Insert(this IDAC dac, DataRow row, bool ommitAutoIncrementPK = true)
        {
            var cols         = row.Table.Columns.Cast <DataColumn>();
            var insertValues = cols.Select(c => new ColumnValue(c.ColumnName, row[c.ColumnName]));

            if (ommitAutoIncrementPK && row.Table.PrimaryKey.Length == 1 && row.Table.PrimaryKey[0].AutoIncrement)
            {
                insertValues = insertValues.Except(new ColumnValue(row.Table.PrimaryKey[0].ColumnName, row[row.Table.PrimaryKey[0].ColumnName]));
            }

            return(dac.Insert(
                       row.Table.TableName,
                       insertValues
                       ));
        }
Пример #2
0
 public static async Task <long> InsertAsync(this IDAC dac, string tableName, IEnumerable <ColumnValue> values)
 {
     return(await Task.Run(() => dac.Insert(tableName, values)));
 }
Пример #3
0
 public static long Save(this IDAC dac, DataRow dataRow, bool ommitAutoIncrementPK = true)
 {
     using (var scope = dac.BeginScope(openConnection: true)) {
         return(dataRow.RowState == DataRowState.Added ? dac.Insert(dataRow, ommitAutoIncrementPK) : dac.Update(dataRow));
     }
 }
Пример #4
0
 public virtual long Insert(string tableName, IEnumerable <ColumnValue> values)
 {
     return(DecoratedDAC.Insert(tableName, values));
 }