I'm trying to expose a model class via WCF Data Services that has an ObservableCollection<int> property. When I do so, the WCF Data Service throws:
The server encountered an error processing the request. The exception message is 'The property 'MyProperty' on type 'MyProject.MyClass' is not a valid property. Properties whose types are collection of primitives or complex types are not supported.'
This seems like a rather severe limitation.
I was able to work around this by artificially introducing a new entity wrapper to represent the int:
[DataContract]
public class SelectionEntity
{
[DataMember]
public int Id { get; set; }
[DataMember]
public int Index { get; set; }
}
and changing my property declaration to
public ObservableCollection<SelectionEntity> MyProperty { get; set; }
Is this best practice? It seems rather inefficient and cumbersome to introduce a new entity just to circumvent this limitation.