I'm developing a WCF Rest service with Json and Xml response. I have more than 100 stored procedure in my database.
My aim to avoid multiple operation contarct and get all the data from database so I have declared object as return type as below.
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "GetDetails?type={type}")]
object GetInfo();
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "PostDetails?type={type}")]
object PostInfo(object Entities);
[OperationContract]
[WebInvoke(Method = "PUT", UriTemplate = "EditDetails?type={type}")]
object EditInfo(object Entities);
[OperationContract]
[WebInvoke(Method = "DELETE", UriTemplate = "DeleteDetails?type={type}")]
object DeleteInfo(object Entities);
But i'm facing serialization problem because WCF should return response based on DataContract so operation contract should have respective DataContract
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "GetUserDetails?type={type}")]
List<UserModel> GetInfo();
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "GetXenDetails?type={type}")]
List<XenModel> GetInfo();
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "PostGroupDetails?type={type}")]
List<GroupModel> PostInfo(GroupEntities Entities);
Please any one suggest me which is better option:
1. Should I create more opertion contract with respective DataContract
2. Explicitly convert DB data to Json or Xml and return as object or String
3. Shall i return as Stream