public class FilterCollection : FilterBasePublic Class FilterCollection
Inherits FilterBasetype FilterCollection =
class
inherit FilterBase
endusing System;
using System.Collections.Generic;
using System.Text;
using Firefly.Box.Data.Advanced;
using NUnit.Framework;
using Firefly.Box;
using Firefly.Box.Testing;
namespace TestFirefly.Box.Documentation
{
[TestFixture]
public class WhereUsage
{
[Test]
public void SimpleWhere()
{
var employees = new Pubs.Employees();
employees.InitializeWithTestData();
var bp = new BusinessProcess
{
From = employees
};
bp.Where.Add(employees.JobLevel.IsEqualTo(150));
bp.Run();
bp.Counter.ShouldBe(3);
}
[Test]
public void AddingTwoFiltersBehavesAsAndWould()
{
var employees = new Pubs.Employees();
employees.InitializeWithTestData();
var bp = new BusinessProcess
{
From = employees
};
bp.Where.Add(employees.JobLevel.IsEqualTo(150));
bp.Where.Add(employees.JobId.IsLessThan(9));
bp.Run();
bp.Counter.ShouldBe(1);
}
[Test]
public void UsingAndAndOr()
{
var employees = new Pubs.Employees();
employees.InitializeWithTestData();
var bp = new BusinessProcess
{
From = employees
};
bp.Where.Add(employees.JobLevel.IsEqualTo(150).And(
employees.JobId.IsLessThan(9).Or(
employees.MiddleInitial.IsEqualTo("C"))));
bp.Run();
bp.Counter.ShouldBe(2);
}
[Test]
public void SendingDirectStringToTheDB()
{
var employees = new Pubs.Employees();
employees.InitializeWithTestData();
var bp = new BusinessProcess
{
From = employees
};
bp.Where.Add("{0} in ({1},{2},{3})",employees.MiddleInitial, "M", "R", "A");
bp.Run();
bp.Counter.ShouldBe(9);
}
[Test]
public void UsingCustomInMemoryFilter()
{
var employees = new Pubs.Employees();
employees.InitializeWithTestData();
var bp = new BusinessProcess
{
From = employees
};
//This has a slight performance penalty as this condition is evaluated in memory, and not by the database
bp.Where.Add(() => employees.MiddleInitial == "M" || employees.MiddleInitial == "R" || employees.MiddleInitial == "A");
bp.Run();
bp.Counter.ShouldBe(9);
}
[Test]
public void UsingAPreDefinedFilter()
{
var employees = new Pubs.Employees();
employees.InitializeWithTestData();
var bp = new BusinessProcess
{
From = employees
};
FilterCollection filter = new FilterCollection();
filter.Add(employees.JobLevel.IsEqualTo(150));
filter.Add(employees.JobId.IsLessThan(9));
bp.Where.Add(filter);
bp.Run();
bp.Counter.ShouldBe(1);
}
}
}| FilterCollection | Initializes a new instance of the FilterCollection class. |
| FilterCollection(FilterBase) | Initializes a new instance of the FilterCollection class. |
| FilterCollection(IEnumerableFilterBase) | Initializes a new instance of the FilterCollection class. |
| Add(FilterBase) | Adds a filter to the FilterCollection |
| Add(FuncBoolean) | Adds a filter to the FilterCollection |
| Add(ICustomFilterMember) | Adds a filter to the FilterCollection |
| Add(String, Object) | Adds a custom filter that will be sent directly to the database as a string. |
| And | Creates a new filter that reflects an And relation between this filter and the one specified in the parameter (Inherited from FilterBase) |
| Clear | Clears the filter of all it's content |
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
| Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object) |
| GetHashCode | Serves as the default hash function. (Inherited from Object) |
| GetType | Gets the Type of the current instance. (Inherited from Object) |
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object) |
| Or | Creates a new filter that reflects an Or relation between this filter and the one specified in the parameter (Inherited from FilterBase) |
| ToString | Returns a string that represents the current object. (Inherited from Object) |