Why does the following code of my entity “Person” generates an error in my WCF Data Service:
[System.Data.Services.Common.DataServiceKey("PartitionKey", "RowKey")]
public class Person : TableServiceEntity
{
public string Name { get; set; }
public int Age { get; set; }
... etc
Error:
Request Error
The server encountered an error processing the request. The exception
message is ‘On data context type ‘PersonDataServiceContext’, there is
a top IQueryable property ‘Person’ whose element type is not an entity
type. Make sure that the IQueryable property is of entity type or
specify the IgnoreProperties attribute on the data context type to
ignore this property.’. See server logs for more details. The
exception stack trace is:at
System.Data.Services.Providers.ReflectionServiceProvider.PopulateMetadata(IDictionary22 childTypes, IDictionary
knownTypes, IDictionary2 entitySets) at1.CreateMetadataAndQueryProviders(IDataServiceMetadataProvider&
System.Data.Services.Providers.BaseServiceProvider.LoadMetadata() at
System.Data.Services.DataService
metadataProviderInstance, IDataServiceQueryProvider&
queryProviderInstance, BaseServiceProvider& builtInProvider, Object&
dataSourceInstance) at
System.Data.Services.DataService1.CreateProvider() at1.HandleRequest() at
System.Data.Services.DataService
System.Data.Services.DataService`1.ProcessRequestForMessage(Stream
messageBody) at SyncInvokeProcessRequestForMessage(Object , Object[] ,
Object[] ) at
System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object
instance, Object[] inputs, Object[]& outputs) at
System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&
rpc) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&
rpc) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&
rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean
isOperationContextSet)
What am I doing wrong?
If I add a property called PersonID, the error is gone, but I need to access my entity through the PartitionKey and RowKey, and the DataServiceKey decoration in the class is not doing anything.
I’m using Visual Studio 2012, .NET Framework 4.0, Silverlight 5.
This appears to be a limitation of the Reflection Provider, and probably not an intended limitation. I’ll file this as a bug internally, but here is a workaround until we get to a fix…
You can use the new modifier to hide pass the desired values through/from the base class: