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
参数指定星号值 (*
) ,则会为未显式设置权限的所有实体集设置权限。
产品 | 版本 |
---|---|
.NET Framework | 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |