WCF Data Services Without Entity Framework

I want to provide legacy .net code through WCF data services. But without using the Entity Framework anywhere. Basically, I now populate all my db models once every X hours and dump these models into the cache. Current web services retrieve all the information from this cache. Now I need to convert all this to WCF data services, primarily to support the OData protocol.

What is the easiest and fastest way out (again, without an entity frame)

The following is an example of what my model looks like:

public class Country { public string CountryCode {get; set;} public string CountryName {get; set;} public List<State> ListOfStates {get; set;} } public class State { public string StateCode {get; set;} public string StateName {get; set;} } 

Thanks in advance.

+4
source share
3 answers

You need to use the reflection provider instead of the Entity infrastructure provider β€” a custom context class that is open in the WCF data service. Just keep in mind that the default reflection provider provides read-only data. If you need to update data through the OData service, you will also need to implement the IUpdateble interface in your context class.

+2
source

This is not black magic - but a bit of work.

See this article in the WCF Data Services Advanced Topic article for how you could use, for example. Subsonic for your ORM.

The main steps are:

  • you need to set up IQueryable<T> collections for all your classes - you can do this by having some kind of DataModel or DataContext class that contains all these collections

If you want to be able to insert and update data, you also need to:

  • implement the IUpdatable interface in your "data context" to enable change tracking and processing of CUD operations.
+2
source

I don’t really want to advertise myself, but your problem is the same situation that we have at work. We have adopted the original tools developed by Jonathan Carter to map WCF DataServices with what you want.

Try a look at http://wcfdstoolkit.codeplex.com/ and see if this solves your problem. Documentation is available through links to the Jonathan blog on how to configure and use the toolkit. But I recommend downloading the september release branch to make sure you have all the bug fixes that I have already resolved.

+1
source

Source: https://habr.com/ru/post/1381290/


All Articles