Product Documentation

c-treeDB API for C# - Developers Guide

Previous Topic

Next Topic

Record Filters

c-treeDB .NET allows the user to define filters on the records using CTRecord.SetFilter(). When a filter is set, all records retrieved with this CTRecord will be filtered against the given expression, and just those records that match will be returned.


// set the filter

try

{

ARecord.SetFilter("ZIPCODE == 12345");

}

catch (CTException err)

{

Console.Write("Filter record failed with error {0}\n", err.GetErrorCode());

}


Only the user who sets the filter will have its records filtered. The filter is turned off when the table is closed, or when CTRecord.SetFilter() is called with an empty string as the filter expression.

Important Note: Only one filter may be active per CTRecord per user at once, so if a new filter is set to a CTRecord with an existing filter, the old filter will be overridden.


// terminate the filter

try

{

ARecord.SetFilter("");

}

catch (CTException err)

{

Console.Write("Filter record failed with error {0}\n", err.GetErrorCode());

}


Use CTRecord.GetFilter() to retrieve the current filter expression. If no filters are active, CTRecord.GetFilter() returns an empty string. Use CTRecord.IsFiltered() to test if filters are active for a CTRecord.

When used in the client/server model, this feature has the potential to increase the performance since just the records matching the criteria will be returned, reducing the network traffic.

Record filters, when used in conjunction with sets, provide the c-treeDB .NET API with simple query capabilities.

TOCIndex