Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
SetEntitySetAccessRule Method

DataServiceConfiguration.SetEntitySetAccessRule Method

Sets the permissions for the specified entity set resource.

Namespace:  System.Data.Services
Assembly:  Microsoft.Data.Services (in Microsoft.Data.Services.dll)

public void SetEntitySetAccessRule(
	string name,
	EntitySetRights rights


Type: System.String
The Name of the entity set for which to set permissions.
Type: System.Data.Services.EntitySetRights
The Access rights to be granted to this resource, passed as an EntitySetRights value.


IDataServiceConfiguration.SetEntitySetAccessRule(String, EntitySetRights)

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.

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
    [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 =
© 2015 Microsoft