Condividi tramite


Metodo DataServiceConfiguration.SetEntitySetAccessRule

Imposta le autorizzazioni per la risorsa del set di entità specificato.

Spazio dei nomi  System.Data.Services
Assembly:  Microsoft.Data.Services (in Microsoft.Data.Services.dll)

Sintassi

'Dichiarazione
Public Sub SetEntitySetAccessRule ( _
    name As String, _
    rights As EntitySetRights _
)
'Utilizzo
Dim instance As DataServiceConfiguration
Dim name As String
Dim rights As EntitySetRights

instance.SetEntitySetAccessRule(name, _
    rights)
public void SetEntitySetAccessRule(
    string name,
    EntitySetRights rights
)
public:
virtual void SetEntitySetAccessRule(
    String^ name, 
    EntitySetRights rights
) sealed
abstract SetEntitySetAccessRule : 
        name:string * 
        rights:EntitySetRights -> unit 
override SetEntitySetAccessRule : 
        name:string * 
        rights:EntitySetRights -> unit 
public final function SetEntitySetAccessRule(
    name : String, 
    rights : EntitySetRights
)

Parametri

  • name
    Tipo: System.String
    Nome del set di entità per il quale impostare autorizzazioni.

Implementa

IDataServiceConfiguration.SetEntitySetAccessRule(String, EntitySetRights)

Osservazioni

Quando si specifica un asterisco (*) come valore per il parametro name, le autorizzazioni vengono impostate per tutti i set di entità che non dispongono delle autorizzazioni impostate in modo esplicito.

Esempi

In questo esempio viene mostrata la pagina code-behind per un servizio dati basato su Northwind, con accesso concesso ai set di entità selezionati.

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
using System.Data.Services;
using System.Linq;
using System.ServiceModel.Web;

namespace NorthwindService
{
    [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    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);
            config.DataServiceBehavior.MaxProtocolVersion =
                System.Data.Services.Common.DataServiceProtocolVersion.V3;
        }
    }
}

Vedere anche

Riferimento

DataServiceConfiguration Classe

Spazio dei nomi System.Data.Services

Altre risorse

Configurazione del servizio dati (WCF Data Services)