QueryInterceptorAttribute クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
メソッドの QueryInterceptorAttribute は、指定されたエンティティ セットのクエリ インターセプターとして注釈を付けます。
public ref class QueryInterceptorAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=true, Inherited=true)]
public sealed class QueryInterceptorAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=true, Inherited=true)>]
type QueryInterceptorAttribute = class
inherit Attribute
Public NotInheritable Class QueryInterceptorAttribute
Inherits Attribute
- 継承
- 属性
例
次の例では、 Customers エンティティ セットへのアクセスを制御します。 各Customerは、そのCustomerに関連付けられているOrdersのみを表示できます。
[QueryInterceptor("Orders")]
public Expression<Func<Order, bool>> FilterOrders()
{
return o => o.Customer.Name == /* Current principal name. */;
}
// Insures that the user accessing the customer(s) has the appropriate
// rights as defined in the QueryRules object to access the customer
// resource(s).
[QueryInterceptor ("Customers")]
public Expression<Func<Customer, bool>> FilterCustomers()
{
return c => c.Name == /* Current principal name. */ &&
this.CurrentDataSource.QueryRules.Contains(
rule => rule.Name == c.Name &&
rule.CustomerAllowedToQuery == true
);
}
注釈
エンティティ セット レベルの承認と検証は、 QueryInterceptorAttributeで注釈が付けられたメソッドによって実装されます。 WCF Data Services はセキュリティ ポリシーを実装するのではなく、サービス開発者が独自のセキュリティ規則とビジネス検証を記述するために必要なインフラストラクチャを提供します。
エンティティ セットのアクセス制御と検証は、クエリの構成を使用したクエリ操作によって有効になります。 エンティティ ベースのアクセスを制御するには、次の規則に従ってエンティティごとのメソッド セットを実装します。
メソッドはパブリック スコープを持ち、エンティティ セットの名前をパラメーターとして受け取って、 QueryInterceptorAttributeで注釈を付ける必要があります。
メソッドはパラメーターを受け入れてはなりません。
このメソッドは、エンティティ セットに対して構成されるフィルターである Expression<Func<T, bool>> 型の式を返す必要があります。
コンストラクター
| 名前 | 説明 |
|---|---|
| QueryInterceptorAttribute(String) |
|
プロパティ
| 名前 | 説明 |
|---|---|
| EntitySetName |
インターセプターが適用されるエンティティを含むエンティティ セットの名前を取得します。 |
| TypeId |
派生クラスで実装されている場合は、この Attributeの一意の識別子を取得します。 (継承元 Attribute) |
メソッド
| 名前 | 説明 |
|---|---|
| Equals(Object) |
このインスタンスが指定したオブジェクトと等しいかどうかを示す値を返します。 (継承元 Attribute) |
| GetHashCode() |
このインスタンスのハッシュ コードを返します。 (継承元 Attribute) |
| GetType() |
現在のインスタンスの Type を取得します。 (継承元 Object) |
| IsDefaultAttribute() |
派生クラスでオーバーライドされた場合、このインスタンスの値が派生クラスの既定値であるかどうかを示します。 (継承元 Attribute) |
| Match(Object) |
派生クラスでオーバーライドされた場合、このインスタンスが指定したオブジェクトと等しいかどうかを示す値を返します。 (継承元 Attribute) |
| MemberwiseClone() |
現在の Objectの簡易コピーを作成します。 (継承元 Object) |
| ToString() |
現在のオブジェクトを表す文字列を返します。 (継承元 Object) |
明示的なインターフェイスの実装
| 名前 | 説明 |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
一連の名前を対応する一連のディスパッチ識別子に割り当てます。 (継承元 Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
インターフェイスの型情報を取得するために使用できるオブジェクトの型情報を取得します。 (継承元 Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。 (継承元 Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
オブジェクトによって公開されるプロパティとメソッドへのアクセスを提供します。 (継承元 Attribute) |