I need to build an application that will communicate with multiple versions of the same datastore platform. Each version comes with its own set of libraries, exposing APIs, although the APIs across the libraries remain mostly the same in operation. In c#, is it possible to have a high level object that references the appropriate DLLs for a particular request and passes objects down to generic methods, or do I essentially need to build the methods for each version of the API?
Expressed in a different way, I need to essentially retrieve data from a report object. The report might live on one of three different versions of the same platform. Each of those versions has a different set of libraries exposing the APIs to interact with that version. Conceptually, I'd like to determine the version targeted by the current request, i开发者_JAVA技巧nstantiate the appropriate API set to deal with that version, then pass that object down to generic methods. What I can't work out in my head is how to pass that object down to generic methods without directly referencing the same API libraries in those methods. Is there a way of doing this?
Many thanks, pt
LInQ might be the best solution for your case.
LINQ to Entities provides Language-Integrated Query (LINQ) support that enables developers to write queries against the Entity Framework conceptual model using Visual Basic or Visual C#. Queries against the Entity Framework are represented by command tree queries, which execute against the object context. LINQ to Entities converts Language-Integrated Queries (LINQ) queries to command tree queries, executes the queries against the Entity Framework, and returns objects that can be used by both the Entity Framework and LINQ.
Quick sample/reference at http://naspinski.net/post/Getting-started-with-Linq-To-Entities.aspx
What about WCF service versioning?
Depending on how the datastore is exposed, you may need a proxy to sit between it and the service, so that you can specify its version. See service versioning example.
精彩评论