Amazon.CognitoSync.SyncManager.Internal.SQLiteLocalStorage.DeleteDataset C# (CSharp) Method

DeleteDataset() public method

Deletes a dataset. All the records associated with dataset are cleared and dataset is marked as deleted for future sync.
public DeleteDataset ( string identityId, string datasetName ) : void
identityId string Identity identifier.
datasetName string Dataset name.
return void
        public void DeleteDataset(string identityId, string datasetName)
        {
            DeleteDataset(identityId, datasetName, null);
        }

Same methods

SQLiteLocalStorage::DeleteDataset ( string identityId, string datasetName, List additionalStatements ) : void

Usage Example

        public void SQliteDatasetsTests()
        {
            string dbPath = Path.Combine(PCLStorage.FileSystem.Current.LocalStorage.Path, DB_FILE_NAME);

            string randomId = "old";
            string randomDataset = Guid.NewGuid().ToString();
            using (SQLiteLocalStorage storage = new SQLiteLocalStorage())
            {
                storage.WipeData();
                storage.CreateDataset(randomId, randomDataset);
                storage.PutValue(randomId, randomDataset, "Voldemort", "He who must not be named");

                using (SQLiteConnection connection = new SQLiteConnection(dbPath))
                {
                    string query = "select count(*) from datasets where dataset_name = @dataset_name and identity_id = @identity_id ";
                    using (var sqliteStatement = connection.Prepare(query))
                    {
                        BindData(sqliteStatement, randomDataset, randomId);
                        if(sqliteStatement.Step()==SQLiteResult.ROW)
                        {
                            var count = sqliteStatement.GetInteger(0);
                            Assert.IsTrue(count == 1);
                        }
                        else
                        {
                            Assert.Fail();
                        }

                    }

                    query = "select count(*) from records where dataset_name = @dataset_name and identity_id = @identity_id ";

                    using( var sqliteStatement = connection.Prepare(query))
                    {
                        BindData(sqliteStatement, randomDataset, randomId);
                        if (sqliteStatement.Step() == SQLiteResult.ROW)
                        {
                            var count = sqliteStatement.GetInteger(0);
                            Assert.IsTrue(count == 1);
                        }
                        else
                        {
                            Assert.Fail();
                        }
                    }
                }

                var datasets = storage.GetDatasetMetadata(randomId);
                Assert.IsTrue(datasets.Count == 1);

                var Id = "new";
                storage.ChangeIdentityId(randomId, Id);
                randomId = Id;

                using (SQLiteConnection connection = new SQLiteConnection(dbPath))
                {
                    var query = "select count(*) from datasets where dataset_name = @dataset_name and identity_id = @identity_id ";
                    using (var sqliteStatement = connection.Prepare(query))
                    {
                        BindData(sqliteStatement, randomDataset, randomId);
                        if (sqliteStatement.Step() == SQLiteResult.ROW)
                        {
                            var count = sqliteStatement.GetInteger(0);
                            Assert.IsTrue(count == 1);
                        }
                        else
                        {
                            Assert.Fail();
                        }
                    }


                    query = "select count(*) from records where dataset_name = @dataset_name and identity_id = @identity_id ";
                    using (var sqliteStatement = connection.Prepare(query))
                    {
                        BindData(sqliteStatement, randomDataset, randomId);
                        if (sqliteStatement.Step() == SQLiteResult.ROW)
                        {
                            var count = sqliteStatement.GetInteger(0);
                            Assert.IsTrue(count == 1);
                        }
                        else
                        {
                            Assert.Fail();
                        }
                    }
                }

                storage.DeleteDataset(randomId, randomDataset);

                using (SQLiteConnection connection = new SQLiteConnection(dbPath))
                {
                    var query = "select last_sync_count from datasets where dataset_name = @dataset_name and identity_id = @identity_id";

                    using (var sqliteStatement = connection.Prepare(query))
                    {
                        BindData(sqliteStatement, randomDataset, randomId);
                        if (sqliteStatement.Step() == SQLiteResult.ROW)
                        {
                            var count = sqliteStatement.GetInteger(0);
                            Assert.IsTrue(count == -1);
                        }
                        else
                        {
                            Assert.Fail();
                        }
                    }

                }

                Assert.IsNotNull(storage.GetDatasetMetadata(randomId)[0]);

            }
        }
All Usage Examples Of Amazon.CognitoSync.SyncManager.Internal.SQLiteLocalStorage::DeleteDataset