Partager via


FilterRule Constructor (InputType, FilterStatement[])

Initializes a new instance of the FilterRule class with a table or view input and one or more filter statements.

Espace de noms: Microsoft.SqlServer.NotificationServices.Rules
Assembly: Microsoft.SqlServer.NotificationServices.Rules (in microsoft.sqlserver.notificationservices.rules.dll)

Syntaxe

'Déclaration
Public Sub New ( _
    inputType As InputType, _
    ParamArray filterStatements As FilterStatement() _
)
public FilterRule (
    InputType inputType,
    params FilterStatement[] filterStatements
)
public:
FilterRule (
    InputType^ inputType, 
    ... array<FilterStatement^>^ filterStatements
)
public FilterRule (
    InputType inputType, 
    FilterStatement[] filterStatements
)
public function FilterRule (
    inputType : InputType, 
    ... filterStatements : FilterStatement[]
)

Paramètres

  • inputType
    The InputType that represents the input table or view. This parameter sets the InputType property.

Notes

You can define zero statements for the filterStatements parameter, but you then must define at least one FilterStatement in for the FilterRule using the FilterStatements property.

If you define multiple statements, a statement with an Exclude action takes precedence over a statement with an Include action. If no Include statement is defined, inputs are included by default. Otherwise, inputs are excluded by default.

Exemple

The following example shows how to define a filter over the event view. The inputType for the filter is the Production.Location table. The filterStatements are one condition that defines a SimpleLeafCondition of Name equals Subassembly.

// Subscribe to products in Subassembly location. This
// requires select permissions on all tables in the sample.

//Specify server and database.
Server server = new Server("MyServer");
Database db = server.Databases[nsApplication.DatabaseName];

// Specify tables and views used by the condition.
Table locationTable = db.Tables["Location", "Production"];
Table inventoryTable = db.Tables["ProductInventory", "Production"];
View eventView = db.Views["InventoryTrackerEvents",
    "NS_InventoryTrackerApplication"];

// Filter defining "Subassembly" locations.
FilterRule toolCrib = new FilterRule(
    new TableInputType(db.Tables["Location", "Production"]),
    new SimpleLeafCondition(new FieldValue("Name"),
        SimpleOperator.Equals, "Subassembly"));

// Create subscription and define basic properties.
s = new Subscription(nsApplication, subscriptionClassName);
s.SubscriberId = "Stephanie";
s.Enabled = true;
s.RuleName = "InventoryTrackerRule";
s.SetFieldValue("DeviceName", "myDevice");
s.SetFieldValue("SubscriberLocale", "en-us");

// Define a condition using the filter.
s.Condition = new LinkLeafCondition(
    LinkLeafOperator.Any,
    toolCrib,
    new JoinClause(eventView.Columns["ProductId"],
        inventoryTable.Columns["ProductId"]),
    new JoinClause(inventoryTable.Columns["LocationId"],
        locationTable.Columns["LocationId"]));

// Add subscription.
s.Add();

Plateformes

Plateformes de développement

Pour obtenir la liste des plateformes prises en charge, consultez Configuration matérielle et logicielle requise pour l'installation de SQL Server 2005.

Plateformes cibles

Pour obtenir la liste des plateformes prises en charge, consultez Configuration matérielle et logicielle requise pour l'installation de SQL Server 2005.

Voir aussi

Référence

FilterRule Class
FilterRule Members
Microsoft.SqlServer.NotificationServices.Rules Namespace