0
votes

I have a WPF client application that connects to IIS that hosts WCF Data Services and WCF Services.

Ideally I would like to define a single class that represents a User and then be able to reuse that same class implementation in both the WPF client and web server projects. Therefore my validation code and helper methods are implementation and unit tested just the once in one place. For example...

1, WPF client calls a WCF Services operation and gets back a User entity.
2, WPF client calls WCF Data Services and gets back a User entity.

Is is possible to get WCF Data Services using the same User class as the WCF Service and Entity Framework. If so is it via self tracking entities, POCO classes or some other option?

2
Thanks, but the link you post is over 2 years old and Data Services/Entity Framework have changed significantly in that time. So I suspect there is better solution now. As least I hope so!Phil Wright
I don't think there is a better solution.Ladislav Mrnka
Thanks, I will stick to just using WCF Services and drop the Data Services. Using self tracking entities seems to better option.Phil Wright

2 Answers

0
votes

Seems that you cannot shared the same classes in anything like a meaningful way. So I decided to stick with custom WCF Services instead.

0
votes

Actually it's not so hard. Instead of regular "Add Service Reference" you can generate data service proxy with T4 and then you can use the same namespace to share the same entities. Here is basic T4 template to do that. (the second benefit is the customisation you can do to template)

Here you can find demo project for this (the source is here if you read Hebrew), in the demo I'm using it to blend STE but you can use it with POCO or other entities.