gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-30 01:16:06 26 4
gpt4 key购买 nike

我正在使用 Xamarin Forms 和 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;
}
}

知道如何使用此组件在注销时清理我的 sqlite 数据库吗?谢谢!

最佳答案

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

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

See the code .

关于c# - 如何在注销时清除sqlite数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36656463/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com