views:

30

answers:

1

Hey guys, I hope everyone is doing well.

I have (more-less) a broad question referring to exposing a model to various clients.

Here is my situation: I have a model (sitting on top of Oracle) that is created using EF 4.0 and 3rd party Oracle provider. The model resides in a library so it can be easily referenced by multiple projects.

My goal is to make the model consumable by as many types of clients as possible:

  1. .Net client code (Silverlight, WPF and ASP.Net, services, etc.).
  2. MS Office apps (Excel)

Now, I don’t want to get into the business of creating custom methods over the Model (e.g. GetCustomersWhoAreVeryUpsetOrderedByUpsetRank()). I’d like to be able to expose the model in such way that the client code can decide (at run time) how to construct the queries. Should I take in IQueriable, execute it in a service and return the result data set? Or do I let the client do all the work via the model?

I did give oData a shot but it appears that the client side library used to write Linq queries against the model is rather limiting. In addition the protocol does not support updates.

So my question is what is the best approach/technology/implementation in exposing the Model based on the above mentioned criteria?

Many thanks in advance.

+1  A: 

I'd advice you not to share your model 1:1 with your clients or reuse it 1:1 for different clients.

To share with stakeholders, use some simple DTOs. The mapping code can be created automatically with a CASE tool, T4 transformation or any other source code creation. If you share your own model, you run into problems as soon as you have to / want to refactor something or if one client has some specific requirements.

Almost same depends on the query methods from EF (the DAL). Define some DataMappers interfaces with common requirements and implement a default behavior. If you ever need your GetCustomersWhoAreVeryUpsetOrderedByUpsetRank(), you are sill fine since you can add this query to a data mapper deriving from the default mapper. With this approach the core system stays clear and reusable and each client is able to get her/his custom features.

Greets Flo

Florian Reischl