L
LW
Hi!
I have a DataSet and a class in my Web Service.
My output for example is:
<OrderInfo>
<CustomerID>VINET</CustomerID>
<OrderID>10248</OrderID>
<OrderDate>07/07/1996</OrderDate>
<ShippedDate>08/08/1996</ShippedDate>
</OrderInfo>
I would like it to be:
<OrderInfo>
<CustomerID>VINET</CustomerID>
<OrderID>10248</OrderID>
<Dates>
<OrderDate>07/07/1996</OrderDate>
<ShippedDate>08/08/1996</ShippedDate>
</Dates>
</OrderInfo>
What I am trying to do is group certain columns from my DataSet so
my XML output is like the one above. I was wondering if using
nested classes would be the way to go but have tried a few things
but none have worked. I tried to declare dates as an inner class but
got confused due to it being an array etc. Can anyone please help?
My code is as follows:
// the class looks like the following
public class OrderInfo {
public string CustomerID;
public int OrderID;
public DateTime OrderDate;
public DateTime ShippedDate;
public class OrderInfo() {}
}
[WebMethod]
public OrderInfo[] GetCustomersOrdersInfo(string custID, int year)
{
//Get the data
DataSet _data = GetCustomersOrders(custID, year);
DataRowCollection _rows = _data.Tables[0].Rows;
// Allocate the array
OrderInfo[] info = new OrderInfo[_rows.Count];
// Fill the array
int i=0;
foreach(DataRow _row in _rows)
{
OrderInfo o = new OrderInfo();
o.CustomerID = _row["CustomerID"].ToString();
rderID = Convert.ToInt32(_row["OrderID"]);
rderDate = DateTime.Parse(_row["OrderDate"].ToString());
o.ShippedDate =
DateTime.Parse(_row["ShippedDate"].ToString());
info[i++] = o;
}
return info;
}
Any help or hints will be greatly appreciated!
Laura
I have a DataSet and a class in my Web Service.
My output for example is:
<OrderInfo>
<CustomerID>VINET</CustomerID>
<OrderID>10248</OrderID>
<OrderDate>07/07/1996</OrderDate>
<ShippedDate>08/08/1996</ShippedDate>
</OrderInfo>
I would like it to be:
<OrderInfo>
<CustomerID>VINET</CustomerID>
<OrderID>10248</OrderID>
<Dates>
<OrderDate>07/07/1996</OrderDate>
<ShippedDate>08/08/1996</ShippedDate>
</Dates>
</OrderInfo>
What I am trying to do is group certain columns from my DataSet so
my XML output is like the one above. I was wondering if using
nested classes would be the way to go but have tried a few things
but none have worked. I tried to declare dates as an inner class but
got confused due to it being an array etc. Can anyone please help?
My code is as follows:
// the class looks like the following
public class OrderInfo {
public string CustomerID;
public int OrderID;
public DateTime OrderDate;
public DateTime ShippedDate;
public class OrderInfo() {}
}
[WebMethod]
public OrderInfo[] GetCustomersOrdersInfo(string custID, int year)
{
//Get the data
DataSet _data = GetCustomersOrders(custID, year);
DataRowCollection _rows = _data.Tables[0].Rows;
// Allocate the array
OrderInfo[] info = new OrderInfo[_rows.Count];
// Fill the array
int i=0;
foreach(DataRow _row in _rows)
{
OrderInfo o = new OrderInfo();
o.CustomerID = _row["CustomerID"].ToString();
rderID = Convert.ToInt32(_row["OrderID"]);
rderDate = DateTime.Parse(_row["OrderDate"].ToString());
o.ShippedDate =
DateTime.Parse(_row["ShippedDate"].ToString());
info[i++] = o;
}
return info;
}
Any help or hints will be greatly appreciated!
Laura