私はXamarin.iOSアプリケーション用にAzure Mobile Servicesを使用しています。バックエンドとクライアント側の両方にApp Serviceを設定しているので、アプリにアカウントを正常に登録し、バックエンドの各テーブルのエントリを確認することができます。Azure Mobileサービス - IMobileServiceSyncTable PullAsyncはローカル同期テーブルを埋めません
ただし、ローカルテーブルを作成するときに、PullAsync
への呼び出しを使用すると、クエリのフィルタを使用せずに、そのテーブルのすべてのレコードを返すときでも、同期テーブルは常に空です。
例外がない場合でも、なぜPullAsync
に同期テーブルが設定されないのかわかりません。
以下は私のコードです:
右新規ユーザの登録が成功した後、ローカル・ストア
public class AzureMobileClientServiceDataManager : IAzureMobileClientServiceDataManager, IMobileServiceSyncHandler
{
const string localDbPath = "sample.db";
MobileServiceSQLiteStore store;
MobileServiceClient client { get; set; }
public AzureMobileClientServiceDataManager(IAzureMobileClientService azureMobileClientService)
{
CurrentPlatform.Init();
SQLitePCL.CurrentPlatform.Init();
//Initialize the Mobile service client with the Mobile App URL,Gatewaty URL and Key
client = azureMobileClientService.GetMobileServiceClientInstance();
}
public async Task InitializeStoreAsync()
{
store = new MobileServiceSQLiteStore(localDbPath);
store.DefineTable<Account>();
store.DefineTable<UserProfile>();
store.DefineTable<Purchase>();
await client.SyncContext.InitializeAsync(store, this);
}
public MobileServiceClient GetInstance()
{
return client;
}
public Task OnPushCompleteAsync(MobileServicePushCompletionResult result)
{
foreach (var error in result.Errors)
{
Console.WriteLine("Error :" + error.RawResult);
}
return Task.FromResult(0);
}
public Task<JObject> ExecuteTableOperationAsync(IMobileServiceTableOperation operation)
{
return operation.ExecuteAsync();
}
}
public interface IAzureMobileClientServiceDataManager
{
Task InitializeStoreAsync();
MobileServiceClient GetInstance();
}
の初期化、私は私のテーブルを埋めるために、この関数を呼び出します。
public async Task<Result<bool>> PopulateData()
{
try{
await accountTable.PullAsync("localAccount", accountTable.Where(ac => ac.Id == mobileServiceClient.CurrentUser.UserId));
await userProfileTable.PullAsync("localUserProfile", userProfileTable.Where(up => up.AccountId == mobileServiceClient.CurrentUser.UserId));
return Result<bool>.Success(true);
}catch(Exception ex)
{
return Result<bool>.Failure(ex, ex.StackTrace);
}
}