[This is preliminary documentation and is subject to change.]

Gets the columns that are used in this ModuleController

Namespace:  Firefly.Box.Advanced
Assembly:  Firefly.Box (in Firefly.Box.dll) Version: 3.4.23.6473 (3.4.23.6473)

Syntax

C#
public ColumnCollection Columns { get; }
Visual Basic (Declaration)
Public ReadOnly Property Columns As ColumnCollection
Visual C++
public:
virtual property ColumnCollection^ Columns {
	ColumnCollection^ get () sealed;
}

Implements

ITask..::.Columns

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.

Examples

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.
CopyC#
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);
            });
        }

    }
}

Examples

Reevaluation of relations
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.
This example is based on test data. The code for the entities included in this test data can be found in the documentation of Entity
CopyC#
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 ReevaluationOfRelations
    {
        [Test]
        public void RelationReevaluation()
        {
            var jobs = new Pubs.Jobs();
            jobs.InitializeWithTestData();

            var bp = new BusinessProcess();
            var selectedJobId = new NumberColumn
            {
                DefaultValue = 1
            };
            bp.Relations.Add(jobs, jobs.Id.IsEqualTo(selectedJobId));
            bp.Columns.Add(selectedJobId);

            bp.Columns.Add(jobs.Id, jobs.Description);//The relation columns are selected after the column that
            // the relation is based on
            bp.ForFirstRow(() =>
            {
                selectedJobId.ShouldBe(1);//The default value
                jobs.Description.ShouldBe("New Hire - Job not specified");//The job with id = 1
                selectedJobId.Value = 5;
                jobs.Description.ShouldBe("Publisher");//The relation reevaluated and fetched 
                //the row with id = 5 - the publisher row
            });
        }
        [Test]
        public void RelationReevaluationCommonError()
        {
            var jobs = new Pubs.Jobs();
            jobs.InitializeWithTestData();

            var bp = new BusinessProcess();
            var selectedJobId = new NumberColumn
            {
                DefaultValue = 1
            };
            bp.Relations.Add(jobs, jobs.Id.IsEqualTo(selectedJobId));

            bp.Columns.Add(jobs.Id, jobs.Description);// The common error is that the relation columns
            //were selected before the column that the relation is based on (SelectedJobId) 
            //thus the relation will be evaluated when the row is entered, but not evaluated when
            //the value of SelectedJobId is changed
            bp.Columns.Add(selectedJobId);


            bp.ForFirstRow(() =>
            {
                selectedJobId.ShouldBe(1);//The default value
                jobs.Description.ShouldBe("New Hire - Job not specified");//The job with id = 1
                selectedJobId.Value = 5;
                selectedJobId.ShouldBe(5);
                jobs.Description.ShouldBe("New Hire - Job not specified");//The relation did not reevaluate
            });
        }
    }
}

See Also