Jazyk

DataServiceConfiguration.SetEntitySetAccessRule Metoda

Definice

Nastaví oprávnění pro zadaný prostředek sady entit.

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)

Parametry

name
String

Název sady entit, pro kterou se mají nastavit oprávnění.

rights
EntitySetRights

Přístupová práva, která mají být udělena tomuto prostředku, předána EntitySetRights jako hodnota.

Implementuje

Příklady

Tento příklad ukazuje stránku kódu pro datovou službu založenou na Northwindu s přístupem uděleným vybraným sadám entit.

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

Poznámky

Když pro parametr zadáte hodnotu hvězdičky (*), name nastaví se oprávnění pro všechny sady entit, které nemají explicitně nastavená oprávnění.

Platí pro

Viz také