Group Class

Returned by BusinessProcess.Groups to group on a column.

Definition

Namespace: Firefly.Box
Assembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
C#
public class Group
Inheritance
Object    Group

Remarks

This interface represents the commands that will be invoked when the columns value is changed. Read Groups for more information.

Example

Groups
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
C#
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Firefly.Box;
using Firefly.Box.Testing;

namespace TestFirefly.Box.Documentation
{
    [TestFixture]
    public class GroupsDemo
    {
        [Test]
        public void GroupsDemo1()
        {
            var employees = new Pubs.Employees();
            var jobs = new Pubs.Jobs();
            employees.InitializeWithTestData();
            jobs.InitializeWithTestData();

            var bp = new BusinessProcess()
            {
                From = employees
            };
            bp.Relations.Add(jobs, jobs.Id.IsEqualTo(employees.JobId));
            bp.OrderBy.Segments.Add(employees.JobId);
            bp.Where.Add(employees.JobId.IsLessOrEqualTo(5));

            var g = bp.Groups.Add(employees.JobId);

            string resultingReport = "";
            int numberOfEmployeesPerJob = 0;
            g.Enter += () =>
            {
                numberOfEmployeesPerJob = 0;
                resultingReport += jobs.Description.Value.Trim() + ":\n";
            };
            bp.LeaveRow += () =>
            {
                resultingReport += employees.LastName.Value.Trim() + "\n";
                numberOfEmployeesPerJob++;
            };
            g.Leave +=
                () =>
                resultingReport +=
                "Total for job " + jobs.Description.Value.Trim() + " - " + numberOfEmployeesPerJob + "\n";
            bp.Run();

            resultingReport.ShouldBe(
            "Chief Executive Officer:\n" +
            "Cramer\n" +
            "Total for job Chief Executive Officer - 1\n" +
            "Business Operations Manager:\n" +
            "Devon\n" +
            "Total for job Business Operations Manager - 1\n" +
            "Chief Financial Officier:\n" +
            "Chang\n" +
            "Total for job Chief Financial Officier - 1\n" +
            "Publisher:\n" +
            "Hernadez\n" +
            "Labrune\n" +
            "Lebihan\n" +
            "Pontes\n" +
            "Henriot\n" +
            "Muller\n" +
            "Ottlieb\n" +
            "Total for job Publisher - 7\n");

        }
    }
}

Properties

Methods

EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
ToStringReturns a string that represents the current object.
(Inherited from Object)

Events

Enter Fired when the value monitored by Groups was changed. The value visible is the new value
Leave Fired when the value monitored by Groups is about to change. The value visible is the old value.

See Also