コード例 #1
0
        public void AddItem(ItemViewModel newItem)
        {
            // add to collection
            Items.Add(newItem);

            // Add to database
            localDb.Items.InsertOnSubmit(newItem);

            // Save changes to database
            localDb.SubmitChanges();
        }
コード例 #2
0
        public void DeleteItem(ItemViewModel itemForDelete)
        {
            // Remove from the collection
            Items.Remove(itemForDelete);

            using (localDb)
            {
                // Remove from the database
                if (localDb.DatabaseExists())
                {
                    localDb.Items.DeleteOnSubmit(itemForDelete);

                    // Submit changes to database
                    localDb.SubmitChanges();
                }
            }

         }