BusinessProcessDeleteRowAfterLeavingItIf Method
Sets an expression that determines if the current row will be deleted once left.
Namespace: Firefly.BoxAssembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
public void DeleteRowAfterLeavingItIf(
Func<bool> condition
)
Public Sub DeleteRowAfterLeavingItIf (
condition As Func(Of Boolean)
)
member DeleteRowAfterLeavingItIf :
condition : Func<bool> -> unit
Parameters
- condition FuncBoolean
-
Notice that when the expression evaluates to true, the
LeaveRow event will execute a second time (the first one was when the row was left), this time with Delete
Activity property
This example demonstrates the usage of DeleteRowAfterLeavingIt
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 DeleteRowAfterLeavingIt
{
[Test]
public void Demo()
{
var employees = new Pubs.Employees();
employees.InitializeWithTestData();// Insert test data to the table
employees.CountRows().ShouldBe(43);// Verifies that the test data has 43 rows
var bp = new BusinessProcess
{
From = employees
};
bp.DeleteRowAfterLeavingItIf(() => employees.MiddleInitial == "");// Settings the Delete row condition
int numberOfLeaveRowInUpdateActivity = 0;
int numberOfLeaveRowInDeleteActivity = 0;
int numberOfLeaveRowExecutions = 0;
bp.LeaveRow += ()=>
{
if (bp.Activity == Activities.Update)//Counting executions for update activity
{
numberOfLeaveRowInUpdateActivity++;
}
if (bp.Activity == Activities.Delete)//Counting executions for Delete activity
{
numberOfLeaveRowInDeleteActivity++;
}
numberOfLeaveRowExecutions++;
};
bp.Run();
numberOfLeaveRowInUpdateActivity.ShouldBe(43);//The leave row was executed once for each employee in update mode
numberOfLeaveRowInDeleteActivity.ShouldBe(10);//The leave row was executed again for the 10 employees that matches the condition
numberOfLeaveRowExecutions.ShouldBe(53);//The leave row was executed a total of 53 times.
}
}
}