WCF Routes using WebAPI
-
6 martie 2012 06:39
Is is possible to create a WCF Data Service using the pattern used by MapHttpRoute, something as follows:
routes.MapHttpRoute( name: "Account", routeTemplate: "Case/{accountname}", defaults: new DataServiceHostFactory() );where on CreatDataSource - I could get the value of "accountname" to determine some bussiness logic?
Haroon
- Editat de Haroon Said 6 martie 2012 06:41
Toate mesajele
-
7 martie 2012 09:20Moderator
Hi Haroon,
Welcome!
I think you can refer this blog: http://blogs.msdn.com/b/rjacobs/archive/2010/04/05/using-system-web-routing-with-data-services-odata.aspx
Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

-
7 martie 2012 14:55
Hi Alan,
Thanks, but I need a little more of a dynamic route. In our enviornment we have large set of databases (in the 1,000s) that have identical schema. Ideally the WCF DataService URI would look like
http://Server/ServiceName/{Guid or some unique Name}/EntitySet
This way I can use the same WCF Data Service and based upon {Guid or some unqiue Name} I can determine what connection string to use on DataSourceCreate.
I can offcourse can get the client to use HTTP header to pass the same information, but would prefer a dynamic routing solution.
Haroon
-
8 martie 2012 06:21Moderator
Very similar behavior is actually implement in the demo service (http://services.odata.org/(S(ijbhhu0l0r0innwms3gkqq3z))/OData/OData.svc/). This service doesn't run against a database, but I'm sure you can easily modify it to do so.
The source code is available here: http://www.odata.org/developers/odata-sdk, in the Sample services section, Read-Write sample service.
Thanks,
Vitek Karas [MSFT]
- Marcat ca răspuns de Alan_chenModerator 14 martie 2012 06:51