internal void RecreateDatabase()
        {
            // purge
            db.Categories.DeleteAllOnSubmit(db.Categories);
            db.Widgets.DeleteAllOnSubmit(db.Widgets);
            db.SubmitChanges();

            // create new
            _category1 = new Category() { CategoryName = "Category 1" };
            _category2 = new Category() { CategoryName = "Category 2" };

            db.Categories.InsertOnSubmit(_category1);
            db.Categories.InsertOnSubmit(_category2);

            db.Widgets.InsertOnSubmit(new Widget() { WidgetName = "Widget 1", WidgetCategory = _category1 });
            db.Widgets.InsertOnSubmit(new Widget() { WidgetName = "Widget 2", WidgetCategory = _category2 });
            db.Widgets.InsertOnSubmit(new Widget() { WidgetName = "Widget 3", WidgetCategory = _category1 });
            db.Widgets.InsertOnSubmit(new Widget() { WidgetName = "Widget 4", WidgetCategory = _category2 });
            db.Widgets.InsertOnSubmit(new Widget() { WidgetName = "Widget 5", WidgetCategory = _category1 });

            counter = 6;

            db.SubmitChanges();
            Refresh();
        }
        public void Refresh()
        {
            // ensure that data exists - just for this test app
            if (db.Categories.Count() == 0 || db.Widgets.Count() == 0)
            {
                RecreateDatabase();
            }

            Widgets = null;
            Widgets = new ObservableCollection<Widget>(db.Widgets);
            _category1 = db.Categories.First();
            _category2 = db.Categories.Skip(1).Take(1).First();
        }