SmartDeviceProject1.SqlCeStorageHandler.TombstoneList C# (CSharp) Method

TombstoneList() public method

public TombstoneList ( SqlCeOfflineEntity entity ) : void
entity SqlCeOfflineEntity
return void
        public void TombstoneList(SqlCeOfflineEntity entity)
        {
            var list = (List)entity;

            using (var connection = GetSqlCeConnection())
            {
                var transaction = connection.BeginTransaction();

                try
                {

                    using (var command = new SqlCeCommand())
                    {
                        command.Connection = connection;
                        command.CommandText = TOMBSTONE_TAGITEMMAPPING_FOR_LIST;
                        command.Parameters.Add("@ListID", SqlDbType.UniqueIdentifier).Value = list.ID;

                        command.ExecuteNonQuery();
                    }

                    using (var command = new SqlCeCommand())
                    {
                        command.Connection = connection;
                        command.CommandText = TOMBSTONE_ITEMS_FOR_LIST;
                        command.Parameters.Add("@ListID", SqlDbType.UniqueIdentifier).Value = list.ID;

                        command.ExecuteNonQuery();
                    }

                    using (var command = new SqlCeCommand())
                    {
                        command.Connection = connection;
                        command.CommandText = TOMBSTONE_LIST;
                        command.Parameters.Add("@ID", SqlDbType.UniqueIdentifier).Value = list.ID;

                        command.ExecuteNonQuery();
                    }

                    transaction.Commit();
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    throw;
                }
            }
        }

Usage Example

Esempio n. 1
0
        private void menuItem5_Click(object sender, EventArgs e)
        {
            var listItem = ListBoxLists.SelectedItem as List;

            if (null != listItem)
            {
                var storageHandler = new SqlCeStorageHandler();
                storageHandler.TombstoneList(listItem);
            }

            RefreshLists();
        }