You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
915 B
35 lines
915 B
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using FLocal.Core.DB;
|
|
|
|
namespace FLocal.Common.actions {
|
|
public static class ChangeSetUtil {
|
|
|
|
internal static void WithChangeSet(Action<ChangeSet, Transaction> action) {
|
|
using(ChangeSet changeSet = new ChangeSet()) {
|
|
Config.Transactional(transaction => {
|
|
action(changeSet, transaction);
|
|
changeSet.Apply(transaction);
|
|
});
|
|
}
|
|
}
|
|
|
|
internal static void WithChangeSet(Action<ChangeSet> action) {
|
|
WithChangeSet((changeset, transaction) => action(changeset));
|
|
}
|
|
|
|
public static void ApplyChanges(params AbstractChange[] changes) {
|
|
using(ChangeSet changeSet = new ChangeSet()) {
|
|
foreach(AbstractChange change in changes) {
|
|
changeSet.Add(change);
|
|
}
|
|
Config.Transactional(transaction => {
|
|
changeSet.Apply(transaction);
|
|
});
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|