Is there an equivalent DataServiceContext.Set (type) for DbContext.Set (type)

I recently created a fairly robust API built around the Entity Framework DbContext. I use a lot of metadata and use the fact that I can get my data with a call of type DbContext.Set (typeof (Customer)). Only in my API I do not know at compile time what type I will pass to the Set method. This works very well with EntityFramework, and I would like to add another layer abstraction and work with it with both EntityFramework and DataServiceContext. So, I really have two questions.

First, more specifically, is there a DataServiceContext (i.e. odata / wcf) equivalent to the DbContext.Set (type) method?

Secondly, and overall, is there a good resource that compares the APIs provided by DbContext with DataServiceContext?

+4
source share
2 answers

EntityFramework and DataServices APIs should not be mixed. Although they look the same, they are not. DbSet is a collection of objects. I do not think that in the DataServiceContext there is a strong contract around sets of objects. Instead, the name of the set of objects is passed to methods that need to know this (for example, see the DataServiceContext.AddObject() or DataServiceContext.CreateQuery() methods) as strings. In a way, this makes programming a DataServiceContext dynamically easier. On the other hand, you still need to know what is on the other side of the pipe (i.e. the server). As stated above, WCF Data Services and EntityFramework are different technologies (although they can work together), and their APIs, although similar, serve different purposes. Therefore, comparing them would be similar to comparing apples with oranges.

+1
source

The client-side DbContext API does not match the server-side DbContext. The main goal is to expose the data and the model, which can be done pretty well. I think you can redefine your application because WCF Data Services can provide enough functionality.

Here is a link from Ladislav Mrnka, which is very well versed in the entity infrastructure, it shows how you could expose your reliable api using WCF data services.

Deploy a WCF Data Service Using the Repository Template

0
source

All Articles