addObject is ignoring me

Aug 27, 2010 at 12:02 AM

I'm tring to add a new object using the sample code from the documentation and nothing happens.  I don't understand why this code tests state == unchanged before adding an entry to the collection.  Should be != unchanged?

/**

 * Constructs a new SaveResult Object.

 *  @param ObjectContext m_context The m_context object.

 */    

- (id) initWithObjectContext:(ObjectContext*)anObjectContext saveChangesOptions:(NSInteger)aSaveChangesOptions

{

         if(self = [super init])

         {

            if([[[anObjectContext getCredentials] getCredentialType] isEqualToString:@"AZURE"])

                        m_isAzureRequest = YES;

            else

                        m_isAzureRequest = NO;

           

            m_entryIndex = 0;

           

            [self setContext:anObjectContext];

           

            Dictionary *mergedDictionary = [Dictionary Merge:[m_context getObjectToResource] dictionary2:[m_context getBindings] propertyName:@"State" propertyValue:Unchanged condition:NO];

            m_changedEntries = [mergedDictionary sortObjects];

            [self setBatchBoundary:[NSString stringWithFormat:@"batch_%@",[ODataGUID NewGuid]]];

            [self setChangesetBoundry:[NSString stringWithString:@""]];

            m_completed = NO;

            //m_entryIndex = -1;

            m_processingMediaLinkEntry = NO;

            m_processingMediaLinkEntryPut = NO;

            m_mediaResourceRequestStream = nil;

            m_operationResponses = [[NSMutableArray alloc]init];

            m_changeOrderIDToHttpStatus = [[NSMutableDictionary alloc]init];

           

            if(aSaveChangesOptions == None)

            {

                        NSArray *entries = [[m_context getObjectToResource] values];

                        if(entries)

                        {

                                    NSUInteger count = [entries count];

                                    for(NSUInteger index = 0; index < count; ++index)

                                    {

                                                ResourceBox* resourceBox = (ResourceBox*)[entries objectAtIndex:index];

                                                if(resourceBox)

                                                {

                                                            if( ( [resourceBox getState] == Unchanged )&& ( [resourceBox getSaveStream]  != nil) )

                                                            {

                                                                        [m_changedEntries addObject:resourceBox];

                                                            }

                                                }

                                    }

                        }

            }

         }

         return self;

}