CustomFilterCollector Delegate
Used to send a custom filter to the database
Namespace: Firefly.Box.Data.AdvancedAssembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
public delegate void CustomFilterCollector(
string filter,
params Object[] args
)
Public Delegate Sub CustomFilterCollector (
filter As String,
ParamArray args As Object()
)
type CustomFilterCollector =
delegate of
filter : string *
args : Object[] -> unit
Parameters
- filter String
-
- args Object
-
CustomMemberFilter
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;
using System.Collections.Generic;
using System.Text;
using Firefly.Box.Data;
using Firefly.Box.Data.Advanced;
using NUnit.Framework;
using Firefly.Box;
using Firefly.Box.Testing;
namespace TestFirefly.Box.Documentation
{
[TestFixture]
public class CustomFilterMemberDemo
{
[Test]
public void UsageOfCustomMemberDemo()
{
var employees = new Pubs.Employees();
employees.InitializeWithTestData();
var bp = new BusinessProcess
{
From = employees
};
bp.Where.Add("{0}", new DBIn(employees.JobId,1,3,5,7));//See the DBIn class below
bp.Run();
bp.Counter.ShouldBe(12);
}
class DBIn : ICustomFilterMember
{
NumberColumn _column;
Number[] _values;
public DBIn(NumberColumn column, params Number[] values)
{
_values = values;
_column = column;
}
public void SendFilterTo(CustomFilterCollector sendFilterString)
{
var args = new ArrayList();
var inFunctionArguments = "";
args.Add(_column);
// Create the inside of the in method syntax according to the number of parameters received in the values.
//For a dynamic number of parameters - for Example for three parameters it should look like "{1}, {2}, {3}
foreach (var value in _values)
{
if (inFunctionArguments.Length != 0)
inFunctionArguments += ", ";
inFunctionArguments += "{" + args.Count + "}";
args.Add(value);
}
sendFilterString("{0} in (" + inFunctionArguments + ")", args.ToArray());
}
}
}
}