Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Extract row-column from array of objects
Message
From
28/04/2011 11:30:02
 
 
To
28/04/2011 09:10:19
General information
Forum:
ASP.NET
Category:
LINQ
Environment versions
Environment:
C# 4.0
Miscellaneous
Thread ID:
01508607
Message ID:
01508677
Views:
30
>>>I am connecting to a webservice and getting an array of objects after passing in a SQL Select.
>>>
>>>The same technique will apply to any pulls I do from the backend. The number of "columns" in the returned data will vary
>>>
>>>I am trying to come up with a generic way to extract the data into anything that looks like a data cursor. I would prefer to do it without iterating the collection.
>>>
>>>object[] result = this.Proxy.runQuery(query, limit, offset);
>>>
>>>now I look at result in the watch window
>>>
>>>expanded each "row" is
>>>
>>>[0]
>>>[1]
>>>[2]
>>>etc.
>>>
>>>now if I expand each of those I see
>>>
>>>item
>>>itemfield
>>>
>>>Both have the same collection when expanded
>>>
>>>[0]
>>>[1]
>>>[2]
>>>
>>>etc for name and a value and type columnn ( all the types are java objects)
>>>
>>>I can put in result{0] and see that node but I can't figure out the rest
>>>
>>>result[0].item[0].value would seem logical to me but doesn't work
>>>
>>>I have a feeling this is a standard and there is a way to deal with this
>>>
>>>Anybody???
>>>
>>>How do I create a cursor
>>>
>>>with columns as represented in the second collection and all the values tostring with as many rows as result.count
>
>>
>>If I understood correctly then the 'column names' are repeated in every 'row' which seems wasteful - or am I wrong?
>>IAC is the web service public and, if so, can you share the URL?
>
>There are no column names in the object. Think of it as a treeview
>
>Primary node has one node for each record. Node(2) has two nodes : item and itemField with identical structure and content
>
>the item node has in the value column {object[n]} where n = the number of columns
>
>the child nodes of item are identified by what looks like array elements : [0]. [1] ... [n-1]
>each of those has in the value column (as seen in the debugger - not data column ) the actualy content of the datum.
>
>http://dl.dropbox.com/u/1989748/ObjectArrayInWatchWindow.PNG
>
>Here's a screenshot of the watch window, since the webservice is not public and even getting this far with it has taken writing an fearsome C# wrapper for their API

As Paul suggests try casting the top level objects to anyTypeArray1. Something like this might work:
foreach (anyTypeArray1 xx in result.AsEnumerable())
            {
                IEnumerable<string> rowvalues = from x in xx.Items select x.ToString();
            }
Previous
Reply
Map
View

Click here to load this message in the networking platform