2016-05-01 9 views
1

Windows 10 Storeアプリケーションを作成していますが、PullAsyncメソッドを呼び出すときに問題があります。私はAzure Mobile Appを長い間使用していましたが、私はいつもprivate IMobileServiceTable<MyTable> tableを使っていました。今、私はOffline Syncと呼ばれる何かのMicrosoftのサポートを追加する必要があります。指示に従って、私は成功しなかった。Azure Mobile Appオフライン同期にデータがありません

ここに私のコードです。

using Microsoft.WindowsAzure.MobileServices; 
using Microsoft.WindowsAzure.MobileServices.Sync; 
using Microsoft.WindowsAzure.MobileServices.SQLiteStore; 

private IMobileServiceSyncTable<MyTable> OffTable = App.MobileService.GetSyncTable<MyTable>(); 
private IMobileServiceTable<MyTable> OnTable = App.MobileService.GetTable<MyTable>(); 

protected ovveride async OnNavigatedTo() 
{ 
    if(!App.MobileService.SyncContext.IsInitialized) 
    { 
     var store = new MobileServiceSQLiteStore("localstore.db"); 
     store.DefineTable<MyTable>(); 

     await App.MobileService.SyncContext.InitializeAsync(store); 
    } 

    await OffTable.PullAsync("uniqueID", OffTable.CreateQuery()); 
    var data = await OffTable.ToCollectionAsync(); //return -> nothing 

    var data2 = await OnTable.ToCollectionAsync(); //return -> 50 rows 
} 

そしてMyTable.cs

using Microsoft.WindowsAzure.MobileServices; 
using Newtosoft.Json; 

[DataTable("MyTable")] 
public sealed class MyTable 
{ 
    [JsonProperty] 
    public int ID { get; set;} 


    [JsonProperty] 
    public string Field1 { get; set; } 

    //... 

    [JsonProperty(PropertyName = "version")] 
    [Version] 
    public string Version { get; set; } 


    [JsonProperty(PropertyName = "deleted")] 
    [Deleted] 
    public bool Deleted { get; set; } 


    [JsonProperty(PropertyName = "updatedAt")] 
    [UpdatedAt] 
    public DateTime UpdatedAt { get; set; } 


    [JsonProperty(PropertyName = "createdAt")] 
    [CreatedAt] 
    public DateTime CreatedAt { get; set; } 
} 

ここproject.jsonからの値です:私が間違ってやっている何

"Microsoft.Azure.Mobile.Client": "2.0.1", 
"Microsoft.Azure.Mobile.Client.SQLiteStore": "2.0.1" 

答えて

0

サーバー側に問題がありました。 したがって、基本的にAzure Portal経由でテーブルを作成する必要があります。 SQL Management Studioで作成することもできますが、ポータル経由で作成する場合は、createdAt,updatedAtversiondeletedが正しい形式になります。したがって、テーブルをSQL MGMNT Studioで作成した場合は、ポータルにアクセスしてCreate Tableをクリックし、テーブルの名前を入力します。それはOKです。あなたのデータは、に上書きされません。そして、すべて正常に動作するはずです。

関連する問題