ModuleControllerColumns Property

Gets the columns that are used in this ModuleController

Definition

Namespace: Firefly.Box.Advanced
Assembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
C#
public ColumnCollection Columns { get; }

Property Value

ColumnCollection

Implements

ITaskColumns

Remarks

Columns that are associated with this ModuleController will be part of it's reevaluation mechanism
Any column that is associated with an entity that is added to this list, will be fetched from the database.

The reevaluation engine


The reevaluation engine, causes automatic reevaluation of expressions and relations that are based on columns that were added to this collection.
Any column that is part of this Columns property collection, will be part of the reevaluation engine.
The reevaluation is performed when a row is entered, or a value of a column is changed.
The reevaluation engine affects the following items:

Relation reevaluation behavior - The first column that is associated to a Entity that was added using the Relations property, will determine that Relation's reevaluation.

Example

The reevaluation basic behavior
This example is in the form of Unit Tests. It references the NUnit framework. This framework can be downloaded from www.NUnit.org. For more information about unit testing visit: www.NUnit.org.
C#
using System;
using System.Collections.Generic;
using System.Text;
using Firefly.Box.Data;
using NUnit.Framework;
using Firefly.Box;
using Firefly.Box.Testing;

namespace TestFirefly.Box.Documentation
{
    [TestFixture]
    public class ColumnsCollection
    {
        [Test]
        public void BasicReevaluation()
        {
            var bp = new BusinessProcess();
            NumberColumn a = new NumberColumn(),
                         b = new NumberColumn();
            bp.Columns.Add(a, b);
            b.BindValue(() => a + 5);

            bp.ForFirstRow(() =>
            {
                a.ShouldBe(0);
                b.ShouldBe(5);
                a.Value = 6;
                a.ShouldBe(6);
                b.ShouldBe(11);
            });
        }
        [Test]
        public void ReevaluationIsNotDoneBeforeAnyRowWasEntered()
        {
            var bp = new BusinessProcess();
            NumberColumn a = new NumberColumn(),
                         b = new NumberColumn();
            bp.Columns.Add(a, b);
            b.BindValue(() => a + 5);
            bp.Start += () =>
            {
                a.ShouldBe(0);
                b.ShouldBe(0); //Because a row was not entered, and no value was set,
                //the reevaluation of b was not performed
            };
            bp.ForFirstRow(() =>
            {
                a.ShouldBe(0);
                b.ShouldBe(5);
                a.Value = 6;
                a.ShouldBe(6);
                b.ShouldBe(11);
            });
        }

    }
}

See Also