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

Binds the value of this column to the specified expression

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

Syntax

C#
public void BindValue(
	Func<dataType> expression
)
Visual Basic (Declaration)
Public Sub BindValue ( _
	expression As Func(Of dataType) _
)
Visual C++
public:
void BindValue(
	Func<dataType>^ expression
)

Parameters

expression
Type: System..::.Func<(Of <(dataType>)>)

Remarks

The expression specified will determine the column's value in one of the following scenarios:
  • The column is bound to an entity, and a new row is created
  • The column is NOT bound to an entity, and a row is entered
  • One of the expression's elements change, acording to the reevaluation engine. For more information see Columns

Examples

This example demonstrates the usage of ColumnsCollection
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);
            });
        }

    }
}

See Also