BusinessProcessReadAllRows Method
Namespace: Firefly.BoxAssembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
public void ReadAllRows(
Action runForEachRow
)
Public Sub ReadAllRows (
runForEachRow As Action
)
member ReadAllRows :
runForEachRow : Action -> unit
Parameters
- runForEachRow Action
-
using the read all rows to display each row's precentage of the total value
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
Entityusing 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 ReadAllRows
{
[Test]
public void ReadAllRows1()
{
var jobs = new Pubs.Jobs();
jobs.InitializeWithTestData();
var bp = new BusinessProcess
{
From = jobs
};
bp.Where.Add(jobs.MinLevel.IsGreaterOrEqualTo(50));
var total = 0;
var result = "";
bp.ForEachRow(()=>
{
if(total == 0)
bp.ReadAllRows(() => total += jobs.MinLevel);
result += jobs.Id.ToString().Trim() + " " + (jobs.MinLevel/total*100).ToString("3%").Trim();
});
result.ShouldBe("9 6%" +
"10 6%" +
"11 6%" +
"8 8%" +
"7 9%" +
"6 11%" +
"5 12%" +
"3 14%" +
"4 14%" +
"2 16%");
}
}
}