Dataset and Nested Class???

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();
o_OrderID = Convert.ToInt32(_row["OrderID"]);
o_OrderDate = 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top