1
votes

I have a set of custom entities which reflect the business representation of data. Then I also have a set of entities that map 1-to-1 to the database that represent the storage of the data. My business layer converts between the 2 types and performs any other logic needed. I only expose the custom objects through my service interface.

From what I can tell I cannot use WCF Data Services. Data services

  1. need to be bound directly to a db source (or some slight abstraction of the direct db connection) and,
  2. that results in using the data entities.

Correct me if I'm wrong, but I can't see any way to use WCF Data Services and its built-in queryability with custom entities while using my business layer.

1
For the record, WCF Data Services is very naive. I have a base class with the properties I want to expose in my feed and a child class with additional properties. When WCF-DS goes to serialize to ATOM it attempts to serialize the properties in my child class! It's reflection algorithm is not looking only at the properties in the class type I am handing it. - Brian Shotola
Data Services can also apparently not match-up an interface with its concrete type. If you return an interface type from your Entity properties like this: IQueryable<ISomething> it returns this error: <m:error> <m:code></m:code> <m:message xml:lang="en-US">Internal Server Error. The type 'SomeClass' is not a complex type or an entity type.</m:message> </m:error> - Brian Shotola

1 Answers

2
votes

I do not necessarily agree with that. If you look at the Architecture Overview in http://msdn.microsoft.com/en-us/library/cc668794.aspx you see two other options next to the EF / DB connectivity. You can have Data Service Providers that just take an alternative (your custom) information model made up of queryable CLR classes and expose them using WCF data services.

So if you create your Business Layer using this approach, your custom entities can just as easy be exposed with WCF data services.