Initializes a new instance of the FilterRule class with a table or view input and one or more filter statements.
命名空间: Microsoft.SqlServer.NotificationServices.Rules
程序集: Microsoft.SqlServer.NotificationServices.Rules (in microsoft.sqlserver.notificationservices.rules.dll)
语法
声明
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[]
)
参数
- inputType
 The InputType that represents the input table or view. This parameter sets the InputType property.
- filterStatements
 Zero or more FilterStatement objects used to evaluate the input. This parameter sets the FilterStatements property.
备注
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.
示例
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();
平台
开发平台
有关支持的平台列表,请参阅安装 SQL Server 2005 的硬件和软件要求。
目标平台
有关支持的平台列表,请参阅安装 SQL Server 2005 的硬件和软件要求。
请参阅
参考
FilterRule Class
FilterRule Members
Microsoft.SqlServer.NotificationServices.Rules Namespace