Esempio n. 1
0
        public int ExecuteInTransaction(IEnumerable <DataRecordAction> records)
        {
            var count = 0;

            Database.WithCommand((cmd) => {
                cmd.CommandTimeout = cmd.Connection.ConnectionTimeout;
                foreach (var record in records)
                {
                    switch (record.Action)
                    {
                    case DataAction.Insert:
                        cmd.CommandText = DialectProvider.GetCreateCommand(record.Record);
                        count          += cmd.ExecuteNonQuery();
                        break;

                    case DataAction.Update:
                        cmd.CommandText = DialectProvider.GetUpdateCommand(record.Record);
                        count          += cmd.ExecuteNonQuery();
                        break;

                    case DataAction.Delete:
                        cmd.CommandText = DialectProvider.GetDeleteCommand(record.Record);
                        count          += cmd.ExecuteNonQuery();
                        break;
                    }
                }
            });
            return(count);
        }