xSQL Schema Compare SDK for SQL Server version 12
EntityFilter Class
Members  Example 

Represents an entity filter that is used to exclude database objects based on some predefined criteria.
Object Model
EntityFilter Class
Public NotInheritable Class EntityFilter 
   Implements xSQL.Schema.Core.IKeyedEntity(Of SqlEntityTypeEnum)IEntityFilterEvaluator 
public __gc __sealed class EntityFilter : public xSQL.Schema.Core.IKeyedEntity<SqlEntityTypeEnum>IEntityFilterEvaluator  
An entity filter allows you to exclude database objects based on predefined criteria. You can exclude, for example, tables the name of which starts with temp, views that belong to the schema Sales, store procedures that match a regular expression and more.

An entity filter is created for a specific object type. It contains one or multiple EntityFilterGroup groups combined with an operator. Depending on the GroupOperator, the entity filter can perform one of the followings:

Entity filters are supported on almost all database objects with a few exceptions. To check whether the entity filter can be applied to a particular object type, call the EntityFilterManager.IsEntityTypeSupported method.

Important: Version 10 of the schema compare API includes an important change to the entity filters: the entity filters are used primarily to exclude database objects. If you wish to include an object, which you can still do, the criteria should be "translated" to exclusionary criteria for other objects in the database, using the negate filters in most cases.

To EXCLUDE, for example, the Employee table, use the following filter condition: EntityNameFilterCondition("Employee", EntityFilterConditionTypeEnum.EqualsTo, group) To INCLUDE the Employee table, which is the same as excluding all but the Employee table, use the following filter condition: EntityNameFilterCondition("Employee", EntityFilterConditionTypeEnum.DifferentFrom, group) A filter can have multiple criteria. If the intention is to exclude objects, the criteria are usually combined with the OR operator. If the intention is to include objects, the negate criteria are usually combined with the AND operator.

The group property EntityFilterGroup.IncludeMatches is no longer supported.

The following code creates two entity filters and register them in the EntityFilterManager object. The code is part of the xSQL Schema Compare API samples:
EntityFilterManager filterManager;
 EntityFilter viewFilter;
 EntityFilter procedureFilter;
 EntityFilter functionFilter;
 EntityFilterGroup group;
 // create the filter manager
 filterManager = new EntityFilterManager(EntityFilterExclusionTypeEnum.ExcludeAlways);
  * Create a view filter that contains two conditions:
  *  - 1st condition excludes views the name of which start with tmp
  *  - 2nd condition excludes views the name of which end with temp
  * Conditions are applied to the view name, therefore they are created as EntityNameFilterCondition objects. 
 // create the view filter
 viewFilter = new EntityFilter(SqlEntityTypeEnum.View);
 // create a group for the filter conditions
 group = new EntityFilterGroup(viewFilter);
 group.ConditionOperator = EntityFilterOperatorEnum.OR;
 // add conditions
 group.Conditions.Add(new EntityNameFilterCondition("temp", EntityFilterConditionTypeEnum.StartingWith, group));
 group.Conditions.Add(new EntityNameFilterCondition("tmp", EntityFilterConditionTypeEnum.EndingWith, group));
 // register the filter
 * Create a procedure filter that excludes all databases procedures, except for spSales and spEmployees.
 * - The group operator is AND
 * - The condition used is DifferentFrom
 * It is important to remember that a filter excludes objects that match the filter conditions, 
 * so to include spSales and spEmployees, we use the DifferentFrom criteria.
 // create the procedure filter
 procedureFilter = new EntityFilter(SqlEntityTypeEnum.StoredProcedure);
 // create a group for the filter conditions
 group = new EntityFilterGroup(procedureFilter);
 group.ConditionOperator = EntityFilterOperatorEnum.And;
 // add conditions
 group.Conditions.Add(new EntityNameFilterCondition("spSales", EntityFilterConditionTypeEnum.DifferentFrom, group));
 group.Conditions.Add(new EntityNameFilterCondition("spEmployees", EntityFilterConditionTypeEnum.DifferentFrom, group));
 // register the filter
  * Create a function filter that contains two conditions:
  * - 1st condition excludes user-defined functions that belong to the schema Sales
  * - 2nd condition excludes user-defined functions that belong to the schema HumanResources. 
  * Conditions in this case are applied to the schema, so they are created as EntitySchemaFilterCondition objects. 
  * Since a function can satisfy either one of the conditions, the group filter combines them with the OR operator.
 // create the function filter
 functionFilter = new EntityFilter(SqlEntityTypeEnum.UserDefinedFunction);
 // create a group for the filter conditions
 group = new EntityFilterGroup(functionFilter);
 group.ConditionOperator = EntityFilterOperatorEnum.OR;
 // add conditions
 group.Conditions.Add(new EntitySchemaFilterCondition("Sales", EntityFilterConditionTypeEnum.EqualsTo, group));
 group.Conditions.Add(new EntitySchemaFilterCondition("HumanResources", EntityFilterConditionTypeEnum.EqualsTo, group));            
 // register the filter
 // set the schema compare entity filters
 comparer.EntityFilterManager = filterManager;
Inheritance Hierarchy



Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also


EntityFilter Members
xSQL.Schema.SqlServer.Filter Namespace



┬ęCopyright 2022 xSQL Software. All Rights Reserved.

Send Feedback