RockyMountainHigh
RockyMountainHigh

Reputation: 3021

Routing in WCF data services

I am creating a WCF data service on top of a EF 4.1 code first data model that goes against a multi-tenant database. In order to enforce the rules of accessing the multi-tenancy I want to require a string id (that is required by all of our MVC-based REST services) be passed as part of the url route. So, for example, right now I have a service route like this:

http://mysample.net/mysamplesvc.svc/Users

That returns all users in the db w/o a filter. I want to partition this by client by requiring the client id be passed as part of the request like this:

http://mysample.net/mysamplesvc.svc/client123/Users

If it is not passed-in or is invalid I will handle it as required. However, I do not see any example like this anywhere. I think I must be searching incorrectly as this seems like a pretty common scenario.

TIA!

Upvotes: 2

Views: 501

Answers (1)

Vitek Karas MSFT
Vitek Karas MSFT

Reputation: 13320

The sample service at http://services.odata.org/(S(readwrite))/OData/OData.svc/ does this (it creates a new instance of the data for each (S(...)) in the URL).

The service code is the last sample on this page: http://www.odata.org/ecosystem#samplecode

Upvotes: 1

Related Questions