DataServiceConfiguration.SetEntitySetAccessRule(String, EntitySetRights) DataServiceConfiguration.SetEntitySetAccessRule(String, EntitySetRights) DataServiceConfiguration.SetEntitySetAccessRule(String, EntitySetRights) DataServiceConfiguration.SetEntitySetAccessRule(String, EntitySetRights) Method

Definición

Establece los permisos para el recurso de conjunto de entidades especificado.Sets the permissions for the specified entity set resource.

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)

Parámetros

name
String String String String

Nombre del conjunto de entidades para el cual se van a establecer los permisos.Name of the entity set for which to set permissions.

rights
EntitySetRights EntitySetRights EntitySetRights EntitySetRights

Derechos de acceso que se van a conceder a este recurso y que se van a pasar como un valor de EntitySetRights.Access rights to be granted to this resource, passed as an EntitySetRights value.

Implementaciones

Ejemplos

En este ejemplo se muestra la página de código subyacente para un servicio de datos basado en Northwind, con acceso concedido a los conjuntos de entidades seleccionados.This example shows the code-behind page for a Northwind-based data service, with access granted to selected entity sets.

using System.Data.Services;
using System.Linq;
using System.ServiceModel.Web;

namespace NorthwindService
{
    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

Comentarios

Cuando se especifica un valor de un asterisco (*) para el name parámetro, los permisos se establecen para todos los conjuntos de entidades que no tienen los permisos establecidos explícitamente.When you specify a value of an asterisk (*) for the name parameter, permissions are set for all entity sets that do not have the permissions explicitly set.

Se aplica a

Consulte también: