次の方法で共有


FilterRule Class

条件評価の結果に基づいて、入力テーブルまたは入力ビューでのフィルタを定義します。このクラスは継承できません。

名前空間: Microsoft.SqlServer.NotificationServices.Rules
アセンブリ: Microsoft.SqlServer.NotificationServices.Rules (microsoft.sqlserver.notificationservices.rules.dll 内)

構文

'宣言
Public Class FilterRule
    Inherits RuleLogic
public class FilterRule : RuleLogic
public ref class FilterRule : public RuleLogic
public class FilterRule extends RuleLogic
public class FilterRule extends RuleLogic

解説

フィルタ ルールは、テーブルまたはビューでのフィルタを定義します。フィルタ ルールには、"IF <条件> THEN <アクション>" という形式のステートメントが含まれています。ここで、アクションとは定義された条件に基づいて入力内の項目を追加または除外するアクションです。

FilterStatements コレクション内で少なくとも 1 つの FilterStatement を定義する必要があります。

複数のステートメントを定義する場合、Exclude アクションが設定されたステートメントは、Include アクションが設定されたステートメントより優先されます。Include ステートメントが定義されていない場合、入力は既定で追加されます。それ以外の場合、入力は既定で除外されます。

継承階層

System.Object
   Microsoft.SqlServer.NotificationServices.Rules.RuleObject
     Microsoft.SqlServer.NotificationServices.Rules.StoredRuleObject
       Microsoft.SqlServer.NotificationServices.Rules.RuleLogic
        Microsoft.SqlServer.NotificationServices.Rules.FilterRule

使用例

次の例に、イベント ビューに対するフィルタを定義する方法を示します。このフィルタをサブスクリプションで使用すると、一連のイベントは製造フェーズが 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();

スレッド セーフ

この型の public static (Microsoft Visual Basic では共有 ) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。

プラットフォーム

開発プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

対象プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

参照

関連項目

FilterRule Members
Microsoft.SqlServer.NotificationServices.Rules Namespace