Click or drag to resize
CalculationWorks Logo
Ignoring changes on spcific columns in HasChanges
Ignoring changes on spcific columns in HasChanges

In this example a custom implementation is used to ignore value changes on all columns named "Id".

Code Item



Your BcfDataSets class name.


Your BcfDataSetSetups class name.


Custom implementation inheriting BcfTransaction.


Custom implementation inheriting BcfDataSetTransactionFactory.


Custom implementation inheriting BcfDataSetStateIdBehavior.

public class MyTransaction : BcfTransaction {

    protected internal MyTransaction(BcfTransactionBuilder builder) : base(builder) { }

    // returns true if anything other than columns named "Id" were changed
    public bool HasSeriousChanges() {
        return CompensationRepository.Items.Any(
            item => {
                var setValueItem = item as BcfUndoRedoItemSetValue;
                return setValueItem == null || setValueItem.Cell.Column.Name != "Id";
public class MyTransactionFactory : BcfDataSetTransactionFactory {

    protected override BcfTransaction CreateTransaction(BcfTransactionBuilder builder) {
        return new MyTransaction(builder);
public class MyStateIdBehavior : BcfDataSetStateIdBehavior {

    protected override Guid Generate(BcfTransaction transaction) {
        if (((MyTransaction) transaction).HasSeriousChanges()) {
            // there were serious changes -> generate a new state id
            return base.Generate(transaction);
        // no serious changes -> return previous state id
        return Value;
partial class SampleDataSet {

    private Guid acceptedStateIdField;

    public bool HasChanges {
        get {
            return Behavior.StateIdItem.Value != acceptedStateIdField;

    public void AcceptChanges() {
        acceptedStateIdField = Behavior.StateIdItem.Value;
// - modifying DataSetSetup to use my transaction and my state id behavior -
// you should use BCF Editor to add the behaviors
// however - this lines shows how to do this in code
var mySampleDataSetSetup = new SampleDataSetSetup();
mySampleDataSetSetup.BehaviorItems.Add(new MyTransactionFactory());
mySampleDataSetSetup.BehaviorItems.Add(new MyStateIdBehavior());
var mySampleDataSet = new SampleDataSet(mySampleDataSetSetup);
See Also