Brand new to WCF. Could really use some help.
I have a List of (100) objects, with 4 data members. DM1, DM2, DM3, DM4
I have a nest of datacontracts
DC1
List<DC2>
DC2
<DM1 Value=n> (n could be any number below 5, so there could be up to 5 DC2 inside the List in DC1)
List<DC3>
DC3
<DM2 value=n> (n could be any number below 10, so up to 10 DC3 inside the List in DC2)
List<DC4>
DC4
<DM3>
<DM4>
Need to iterate through the original list of objects, and create one datacontract (DC1) with the various nested datacontracts, depending upon the different values within the datamembers of the original list of objects.
e.g.:
<DC1>
<DC2>
<DM1 value = "a">
<DC3>
<DM2 value = 1>
<DC4>
<DM3>
<DM4>
<DM2 value = 2>
<DC4>
<DM3>
<DM4>
<DC4>
<DM3>
<DM4>
</D3>
</DC2>
<DC2>
<DM1 value = "b">
<DC3>
<DM2 value = 1>
<DC4>
<DM3>
<DM4>
<DM2 value = 2>
<DC4>
<DM3>
<DM4>
<DC4>
<DM3>
<DM4>
</D3>
</DC2>
<DC1>
What's the best way of doing this?
Thanks!
Here's the DataContracts along with the service contract using DC1 to pass along the info:
[DataContract]
public class DC1
{
[DataMember]
public string string { get; set; }
[DataMember]
public List<DC2> LDC2{ get; set; }
}
[DataContract] public class DC2 { [DataMember] public string Type{ get; set; }
[DataMember]
public List<DC3> DC3s{ get; set; }
[DataContract] public class DC3 { [DataMember] public decimal num { get; set; }
[DataMember]
public List<DC4> DC4s{ get; set; }
[DataContract] public class DC4 { [DataMember] public int num2{ get; set; }
[DataMember]
public decimal Val{get; set;}
Service Contract: [ServiceContract(Namespace = Constants.Namespace)] public class Service {
[OperationContract]
DC1 GetMethod(int num);
DataSet:
is a LIST<> of the following object:
[Serializable]
public class Data
{
public string Type { get; set; }
public double Num { get; set; }
public double Num2{ get; set; }
public decimal Val{ get; set; }
}
Can have 100 (or more) of these objects in this list. With up to 5 types, with up to 10 of Num, and up to 5 of Num2.
Thanks for the response, and hope this clarifies!