WCF List Array

I am new to WCF/Silveright. I have been converting all datatables into strongly typed Lists<> and then using a proxy to pass the information to Silverlight, which has been working great. I now have a dataset with 3 tables in it and would like to pass all of the data at once. How can I create a List<> array that contains 3 strongly typed Lists<>?
public <!--LIST ARRAY SOME SORT--> OrderSummary(Int32 lngOrderID) {
            //how do I combine, lstOrderItems, lstOrderParts and lstOrders into one return type??
            List<clsOrderItems> lstOrderItems = new List<clsOrderItems>();
            List<clsOrderParts> lstOrderParts = new List<clsOrderParts>();
            List<clsOrders> lstOrders = new List<clsOrders>();
             
            wsOffice.dsOrders ds = objOffice.eOrderLookup(lngOrderID);
            #region ORDER
            foreach (wsOffice.dsOrders.tblOrdersRow dr in ds.tblOrders.Rows) {
                clsOrders obj = new clsOrders();
                obj.blnArchived = dr.blnArchived;
                obj.blnCompleted = dr.blnCompleted;
                obj.bytOrderPartTypeID = dr.bytOrderTypeID;
                obj.dtmCreated = dr.dtmCreated;
                obj.dtmUserDate = dr.dtmUserDate;
                obj.lngAdjustedOrderID = dr.lngAdjustedOrderID;
                obj.lngCreatorID = dr.lngCreatorID;
                obj.lngOrderID = dr.lngOrderID;
                obj.strCountry = dr.strCountry;
                obj.strCreator = dr.strCreator;
                obj.strStatus = dr.strStatus;
                lstOrders.Add(obj);
            }
             
            #endregion
            #region ITEMS
 
            foreach (wsOffice.dsOrders.tblOrderItemsRow dr in ds.tblOrderItems.Rows) {
                clsOrderItems obj = new clsOrderItems();
                obj.blnTaxExempt = dr.blnTaxExempt;
                obj.bytOrderPartTypeID = dr.bytOrderPartTypeID;
                obj.strUnitType = dr.chUnitType;
                obj.intQty = dr.intQty;
                obj.lngItemID = dr.lngItemID;
                obj.lngPriceID = dr.lngPriceID;
                obj.strPartType = dr.strPartType;
                obj.strSKU = dr.strSKU;
                lstOrders.Add(obj);
            }
            #endregion
 
            #region PARTS
            foreach (wsOffice.dsOrders.tblOrderPartsRow dr in ds.tblOrderParts.Rows) {
                clsOrderParts obj = new clsOrderParts();
                obj.blnUplineArchived = dr.blnUplineArchived;
                obj.blnUplineCompleted = dr.blnUplineCompleted;
                obj.dtmPaid = dr.dtmPaid;
                obj.dtmSent = dr.dtmSent;
                obj.lngConsolidatedOrderID = dr.lngConsolidatedOrderID;
                obj.lngOrderID = dr.lngOrderID;
                obj.lngReceiverID = dr.lngReceiverID;
                obj.lngUplineID = dr.lngUplineID;
                obj.strReceiver = dr.strReceiver;
                obj.strUpline = dr.strUpline;
                lstOrderParts.Add(obj);
            }
            #endregion
        }
    }

Open in new window

xmlBabeAsked:
Who is Participating?
 
xmlBabeAuthor Commented:
I found the solution. Create a class that references the 3 table classes and return that main class. Once that is casted to list on the silverlight side, the three referenced classes will be available.
0
 
apeterCommented:
Have a list of datatables like below

List<DataTable> dtList = List<DataTable>();

dtList[<tablename>] will help in extracting a particular table or dtList[<0..n>] can be used to access all the table sequentially.
0
 
apeterCommented:
That is great. I hope you won't get into below situation.
If future, what happens if want you want to add one more table or remove or modify one table, you want to change your code everytime !!!
0
 
xmlBabeAuthor Commented:
Well, if you have to update then you have to update, no getting around that if your interface changes. I actually found an even better solution by using the result type created when calling a stored procedure but is still for just single table type info. I got stuck on returning an array of lists. Your snipet looked like that's what you were saying but I couldn't figure out how to do that without wrapping the table classes in a patent class (if that makes sense ) that solution seems to work fairly well. I just worry that performance wise there's something better.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.