Database Reference
In-Depth Information
InitializeService method. The code below sets the access rule for the specified entities to All, providing
authorization to read, write, delete, and update data for the specified entity set:
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
// TODO: set rules to indicate which entity sets and service operations are visible,
updatable, etc.
// Examples:
config.SetEntitySetAccessRule("Docs", EntitySetRights.All);
config.SetEntitySetAccessRule("UserDocs", EntitySetRights.All);
config.SetEntitySetAccessRule("Users", EntitySetRights.All);
config.SetEntitySetAccessRule("TechGeoInfo", EntitySetRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
If you don't feel like specifying each entity one by one, you can optionally specify all the entities
with a single line, as follows:
config.SetEntitySetAccessRule("*", EntitySetRights.All);
The above line assumes that you want to specify the same rights to all the entities. Not
recommended, but will do for this example. In a production environment you want to more specific with
what rights you specify for each entity.
There are other EntitySetRights options, such as AllRead, AllWrite, None, ReadSingle, and
WriteAppend. You won't cover them all here but you can read about them here:
http://msdn.microsoft.com/en-us/library/system.data.services.entitysetrights.aspx
So far, you've created your Web application, added your data model, and added your WCF Data
Service. Right now your Solution Explorer should look like Figure 6-11.
Figure 6-11. Solution Explorer
Search WWH ::




Custom Search