This is my first time working with WCF DataServices but I was able to get a simple entity-backed service up and running by just referencing my DBContext when I implemented my service class, for example:
public class MyDataService : DataService<MyDBContext>
Then I can simply choose which entities I want to expose and it just works which is pretty cool. But things are never that simple as a developer are they? My scenario is more complicated tough so I have two questions:
- In the simple case of MyDBContext above, I don't have to worry about connection strings because that context reflects a single database that is shared across the entire application so the connection string is just stored in the config and is instantiated with the default constructor. However, I also need to expose access to a second DBContext that is department-specific (lets call it DepartmentDBContext). In other-words depending on who is making the request I need to route them to their specific database (so same context, but instantiated with a different connection string depending on the request). How should this best be handled?
- Aside from DepartmentDBContext which my consumers will have more or less complete access to I need to also expose limited bits and pieces of data that exist in different dbs (and thus different dbcontexts) so I need to build a mechanism to do this without exposing my entire data model. Really all I will need to expose is some Ids and Name properties (so imagine something like DepartmentId, CustomerId, CustomerName, AccountID, AccountName, etc). My thought was just to wrap these properties up into a single POCO and expose that to the consumer since that's all they'll need on their end but I'm not sure how I should write this via WCF DataServices since it will not be tied to a single context.
thanks in advance for any tips or advice you can provide