I'm looking at building a WCF service that can store/retrieve a range of different types. Is the following example workable and also considered acceptable design:
[ServiceContract]
public interface IConnection
{
[OperationContract]
IObject RetrieveObject(Guid ObjectID);
[OperationContract]
Guid StoreObject(IObject NewObject);
}
[ServiceContract]
[ServiceKnownType(IOne)]
[ServiceKnownType(ITwo)]
public interface IObject
{
[DataMember]
Guid ObjectID;
}
[ServiceContract]
public interface IOne:IObject
{
[DataMember]
String StringOne;
}
[ServiceContract]
public interface ITwo:IObject
{
[DataMember]
String StringTwo;
}
When using the service, I would need to be able to pass the child types into the StoreObject method and get them back as their Child type from the RetrieveObject method.
Are there better options?
Thanks, Rob