WCF List Array

Posted on 2009-04-15
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;





            #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;




            #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;






Open in new window

Question by:xmlBabe
    LVL 25

    Expert Comment

    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.

    Accepted Solution

    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.
    LVL 25

    Expert Comment

    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 !!!

    Author Comment

    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.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    In previous Articles, we have discussed how we can upload a file using .asmx web service and isolated storage space. Here, in continuation to the topic, I am going to discuss how we can use WCF for the same purpose. Steps: 1.Create the silverli…
    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…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now