Getting a list of Objects using Odata...

Aug 1, 2011 at 10:29 PM

Okay, I think I am close.  I have a proxy to our Odata/WCF services, but I'm not sure how to put the contents of what I get back into a List/Array/etc...

Here is my code so far...

 CAEntities *proxy = [[CAEntities alloc] initWithUri:@"http://servername/Service.svc" credential:nil];

    //need to do a simple search based on Search Text...then get back a list of "Scripts"...from the Odata Search Service...

   //Also, can I "Expand" objects in Object C???


    DataServiceQuery *qry = [proxy CAModel_Script];
    [qry filter:@"CAModel_Script/m_title eq 'searchtext'"];
   
    QueryOperationResponse *result = [qry execute];
    items = [[result getResult] retain];
   
   
    //cleanup
    [proxy release];

 

I know this code is not correct, but I'm not sure how to put the results into a List/Array/etc...If I was in .NET, no problem, but I'm still figuring out this Obj. C world.

 

Thanks again.

Mark

Aug 13, 2011 at 11:16 PM

Mark,

[result getResult] returns an NSMutableArray object, so your results are already in an array for you to use.

Jon

Nov 3, 2011 at 4:17 PM

Thanks, jonkroll...I can get data back, but when I try "expand" to get Child objects, I get an error everytime.  I've tried several different "types" to expand.  I can't get it to work at all.  Do you have any good troubleshooting ideas?  The services are WCF oData Services.  I can get the main object back, just not the child objects.

 

thanks again.

 

mark