Click here to Skip to main content
15,794,593 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,

I have to create WCF Restful service in .net with c# , i aware about attribute which need to define WCF Restful service , But my query is how to send response from different classes in one response object and response object should be in Json.

Like i have class User having fields id, username and List<role>

public class User
{
public int id { get; set; }
public String username { get; set; }
public List<role> roles { get; set; }
}

So i want to know how to add List of Role response in the same response object of id and username.

Again Role class has another list of operation

public class Role
{
public String username { get; set; }
public List<operation> operations { get; set; }
}


So i want to know how to add list of Operation and Role to the same response of id and username
Posted

1 solution

C#
[DataContract]
public class User
{
[DataMember]
public int id { get; set; }
[DataMember]
public String username { get; set; }
[DataMember]
public List<roles> roles { get; set; }
[DataMember]
public List<response> response{ get; set; }
}

add this in interface.
[OperationContract]
[WebGet]
list<user> GetUserDetails(int id)

</user></response></roles>


thanks
saravanan
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900