C# 如何在注销时清除sqlite数据库

C# 如何在注销时清除sqlite数据库,c#,sqlite,xamarin.forms,azure-mobile-services,offline-mode,C#,Sqlite,Xamarin.forms,Azure Mobile Services,Offline Mode,我正在使用Xamarin表单和WindowsAzure.MobileServices.SQLiteStore NuGet来处理sqlite数据库和azure数据库之间的同步。一切正常,但当我想注销我的用户时,我想清理数据库。这样,在下次登录时,它将再次重新生成数据库并从零开始同步。我已尝试清除表,但这只会删除本地数据,当您重新登录时,它只会同步任何新数据 当前,我的dispose执行以下操作: // Globally declared and initialized in my init() m

我正在使用Xamarin表单和WindowsAzure.MobileServices.SQLiteStore NuGet来处理sqlite数据库和azure数据库之间的同步。一切正常,但当我想注销我的用户时,我想清理数据库。这样,在下次登录时,它将再次重新生成数据库并从零开始同步。我已尝试清除表,但这只会删除本地数据,当您重新登录时,它只会同步任何新数据

当前,我的dispose执行以下操作:

// Globally declared and initialized in my init() method
MobileServiceSQLiteStore store { get; set; }
public MobileServiceClient MobileService { get; set; }

public async Task Dispose()
{
    try
    {
        initialized = false;

        // await this.userTable.PurgeAsync<AzureUser>("CleanUsers", this.userTable.CreateQuery(), CancellationToken.None);

        store.Dispose();
        MobileService.Dispose();

        store = null;
        MobileService = null;
    }
    catch (Exception ex)
    {
        throw ex;
    }
}
//在my init()方法中全局声明和初始化
MobileServiceSQLiteStore存储{get;set;}
公共移动服务客户端移动服务{get;set;}
公共异步任务Dispose()
{
尝试
{
初始化=假;
//等待this.userTable.PurgeAsync(“CleanUsers”,this.userTable.CreateQuery(),CancellationToken.None);
store.Dispose();
MobileService.Dispose();
store=null;
MobileService=null;
}
捕获(例外情况除外)
{
掷骰子;
}
}

您知道如何使用该组件在注销时清理sqlite数据库吗?谢谢

如果要清除所有项目,请使用:

this.userTable.PurgeAsync(null, null, true, CancellationToken.None);

.

清除数据后是否尝试强制同步?这样做
等待MobileService.SyncContext.PushAsync()
after
PurgeAsync()
?@hvaughan3一旦用户重新登录,它将再次同步,但清除的数据不会同步,而是只同步新记录。下面是一个示例:抱歉,我刚刚看到了这一点,因为我更改了需要执行的操作的优先级。purgeAsync方法清除本地数据库,但当用户再次登录时,它只同步azure中添加的新行,而不同步以前清除的行。。。知道为什么会这样吗?