OData client only returning last entry in sequence?

Nov 2, 2010 at 12:38 AM

I'm hoping that I'm just using the API incorrectly, but for some reason, when I query my oData service from wp7, I am only receiving the last entry in the sequence. I'm pretty sure the service is working just fine as I'm able to just visit the odata query URL in the browser and get the correct results. However, the following method only ends up displaying one item on the list. 

I based the following code from the sample at this blog post: http://chriskoenig.net/2010/10/30/odata-v2-and-windows-phone-7/

The observable collection which is passed in is the one which is bound to the wpf listbox.

        private static void LoadRuntimeData(ObservableCollection<CategoryItem> items)
        {
            var catalog = GetCatalog();

            Uri queryUri = new Uri("/Categories?&$orderby=Name", UriKind.Relative);

            var categories = new DataServiceCollection<Category>(catalog);

            var queryHandle = App.ViewModel.StartQuerying();

            categories.LoadAsync(queryUri);
            categories.LoadCompleted += (e, c) =>
                {
                    using (queryHandle)
                    {
                        var serverItems = categories.Select(k => new CategoryItem
                        {
                            Name = k.Name,
                            Description = k.Description
                        });

                        items.Clear();
                        foreach (var item in serverItems)
                        {
                            items.Add(item);
                        }
                    }
                };
        }
Any tips would be greatly appreciated