views:

196

answers:

2

Hello. We use custom type to represent Identifiers in our project. It has TypeConvertor attached and it always helped with serialization.

I've tried to use WCF Data Services to expose some data from our system, but faced a problem. Astoria framework do not recognize class as an entity even though I've decorated it with [DataServiceKey("Id")] attribute. If I change type of property to Guid - it totally works :(.

How could teach WCF Data Services to understand this simple class?

A: 

As long as the class has a property Id DataServices should serialize it properly. You don't even need the attribute if the property is named ID. Did you see the example I did here. Also, you will find a complete list of OData related articles on http://www.Odataprimer.com. Maybe one of those will help.

Darrel Miller
No it isn't true. For System.Data.Services.Providers.ReflectionServiceProvider key property *should* be named ether ID (with capital D) or EntityNameID.
Artem Tikhomirov
You are right, it needs to be ID not Id. My bad.
Darrel Miller
It's OK. Thanks for the answer anyway.
Artem Tikhomirov
A: 

After a bit of research and a ton of Reflector work I've found that it's not possible.

WCF Data Services have monumental external metadata support described in detail by Alex James in very good series of posts.

However primitive data types creation is forbidden and key property of the entity should be of a primitive type. Moreover there is no pre- and post- execution hook available to provide run-time conversion from and to string type.

This and limited support of LINQ from NHibernate makes Astoria pretty unusable for me now. Witch is very sad.

Artem Tikhomirov