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


Represents an entity filter.
Object Model
EntityFilter Class
Syntax
'Declaration
 
Public NotInheritable Class EntityFilter 
   Implements a0(Of SqlEntityTypeEnum), IEntityFilterEvaluator 
public sealed class EntityFilter : a0<SqlEntityTypeEnum>, IEntityFilterEvaluator  
public __gc __sealed class EntityFilter : public a0<SqlEntityTypeEnum>, IEntityFilterEvaluator  
Remarks
An entity filter allows you to include or exclude database objects based on some criteria. You can exclude, for example, database tables the name of which starts with #, ## or temp, include views that belong to the schema Sales, exclude 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. A group can either include or exclude database objects that meet its conditions. 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, use the method EntityFilterManager.IsEntityTypeSupported.

As of version 5, the previous schema filters have been depreciated and replaced by the entity filters.

Example
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. 
 * 
 */
viewFilter = new EntityFilter(SqlEntityTypeEnum.View);
                        
// create a new group
group = new EntityFilterGroup(viewFilter);
// combine the conditions in the group with the OR operator
group.ConditionOperator = EntityFilterOperatorEnum.OR;
// the group should EXCLUDE the views that match the conditions
group.IncludeMatches = false;
                        
// add the group conditions
group.Conditions.Add(new EntityNameFilterCondition("temp", EntityFilterConditionTypeEnum.StartingWith, group));
group.Conditions.Add(new EntityNameFilterCondition("tmp", EntityFilterConditionTypeEnum.EndingWith, group));
viewFilter.Groups.Add(group);
                        
// register the filter
filterManager.Filters.Add(viewFilter);
                        
            
/*
 * Creates the function filter that contains two conditions:
 * - 1st condition includes the user-defined functions that belong to the schema Sales
 * - 2nd condition includes the 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.
 * It is important to remember that the filter will exclude all other database functions that do not meet the filter's criteria. 
 * The only functions that will be compared and synchronized are the ones that belong to the schema Sales or HumanResources.
 * 
 */
functionFilter = new EntityFilter(SqlEntityTypeEnum.UserDefinedFunction);
                        
// create a new group
group = new EntityFilterGroup(functionFilter);
// combines the conditions in the group with the OR operator
group.ConditionOperator = EntityFilterOperatorEnum.OR;
                        
// add the group conditions; both conditions require an exact match of the schema, so the EqualsTo condition type is used
group.Conditions.Add(new EntitySchemaFilterCondition("Sales", EntityFilterConditionTypeEnum.EqualsTo, group));
group.Conditions.Add(new EntitySchemaFilterCondition("HumanResources", EntityFilterConditionTypeEnum.EqualsTo, group));
functionFilter.Groups.Add(group);
                        
// register the filter
filterManager.Filters.Add(functionFilter);
                        
// set the schema compare entity filters
comparer.EntityFilterManager = filterManager;
Inheritance Hierarchy

System.Object
   xSQL.Schema.SqlServer.Filter.EntityFilter

Requirements

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

Reference

EntityFilter Members
xSQL.Schema.SqlServer.Filter Namespace

 

 


┬ęCopyright 2018 xSQL Software. All Rights Reserved.

Send Feedback