Sunday, October 08, 2017

Traveller Tracker - caching the data

Finally got the caching to work.  So, when you select a sector, if you've not used it before, we create a new sector record in the Sector table, then load all the worlds for that sector into the World table (linked by the sector ID).  This is done asynchronously as we've a fast in-memory list of the worlds we use for the display.

If you've already picked that sector before, and we have worlds in it, we load the world data from the local DB.

And I finally got the code for getting the selected items in the combo boxes to work without having to iterate through them all.

               if (App.tmUniverse.Sectors != null)
                {
                    comboSectors.ItemsSource = App.tmUniverse.Sectors.OrderBy(x => x.FirstName);
                    comboSectors.SelectedItem = App.tmUniverse.Sectors.Where(x => x.FirstName == sector.Name).First();
                }
                if (App.tmWorlds != null)
                {
                    comboWorlds.ItemsSource = App.tmWorlds.OrderBy(x => x.Name);
                    comboWorlds.SelectedItem = App.tmWorlds.Where(x => x.WorldID == ship.WorldID).First();
                }


No comments: