?
Solved

WCF List Array

Posted on 2009-04-15
4
Medium Priority
?
1,111 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:xmlBabe
  • 2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:apeter
ID: 24181968
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
 

Accepted Solution

by:
xmlBabe earned 0 total points
ID: 24187283
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
 
LVL 25

Expert Comment

by:apeter
ID: 24190979
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
 

Author Comment

by:xmlBabe
ID: 24207824
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will show you how to add an attribute to an XML (http://en.wikipedia.org/wiki/XML) stream returned from a Windows Communication Foundation (http://en.wikipedia.org/wiki/Windows_Communication_Foundation) (WCF) Web Service.  Some knowled…
Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question