DataServiceConfiguration.SetEntitySetAccessRule 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
為指定的實體集資源設定權限。
public:
virtual void SetEntitySetAccessRule(System::String ^ name, System::Data::Services::EntitySetRights rights);
public void SetEntitySetAccessRule (string name, System.Data.Services.EntitySetRights rights);
abstract member SetEntitySetAccessRule : string * System.Data.Services.EntitySetRights -> unit
override this.SetEntitySetAccessRule : string * System.Data.Services.EntitySetRights -> unit
Public Sub SetEntitySetAccessRule (name As String, rights As EntitySetRights)
參數
- name
- String
要設定使用權限之實體集的名稱。
- rights
- EntitySetRights
要授與此資源的存取權限,以 EntitySetRights 值傳遞。
實作
範例
此範例示範 Northwind 資料服務的程式碼後置頁面,並授與選定實體集的存取權。
public class Northwind : DataService<NorthwindEntities>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
// Grant only the rights needed to support the client application.
config.SetEntitySetAccessRule("Orders", EntitySetRights.AllRead
| EntitySetRights.WriteMerge
| EntitySetRights.WriteReplace);
config.SetEntitySetAccessRule("Order_Details", EntitySetRights.AllRead
| EntitySetRights.AllWrite);
config.SetEntitySetAccessRule("Customers", EntitySetRights.AllRead);
}
}
Imports System.Data.Services
Imports System.Linq
Imports System.ServiceModel.Web
Public Class Northwind
Inherits DataService(Of NorthwindEntities)
' This method is called only once to initialize service-wide policies.
Public Shared Sub InitializeService(ByVal config As DataServiceConfiguration)
' Grant only the rights needed to support the client application.
config.SetEntitySetAccessRule("Orders", EntitySetRights.AllRead _
Or EntitySetRights.WriteMerge _
Or EntitySetRights.WriteReplace)
config.SetEntitySetAccessRule("Order_Details", EntitySetRights.AllRead _
Or EntitySetRights.AllWrite)
config.SetEntitySetAccessRule("Customers", EntitySetRights.AllRead)
End Sub
End Class
備註
當您為 參數指定星號的值 (*
) name
時,會針對未明確設定許可權的所有實體集設定許可權。