首页 文章

Azure移动服务和通用应用程序SQLite同步

提问于
浏览
2

我有一个普通的通用应用程序,没有什么花哨,非常简单 .

有一个SQLite数据库,重量超过200KB(甚至可以是20MB,记住这一点),我想在Windows 8.1和Windows Phone 8.1设备之间共享这个数据库 .

我猜漫游数据还不够,对不对?

所以,我用谷歌搜索并找到Azure移动服务,它真的很甜,但提供的示例太简单了,我不知道如何扩展它 .

我的数据库有7个表,其中一些是通过外键连接的 . 这是我的一个示例(数据库基于它) .

public class Meeting : INotifyPropertyChanged
{
        public Meeting() { }

        private int _id;
        [PrimaryKey, AutoIncrement]
        public int Id { get; set; }

        private int _adressId;
        public int AdressId { get; set; }

        private Adress _adress;
        [Ignore]
        public Adress Adress { get; set; }
}

那就是方法

private async Task InitLocalStoreAsync()
{
    if (!App.MobileService.SyncContext.IsInitialized)
    {
        var store = new MobileServiceSQLiteStore("MyDatabase.db");
        store.DefineTable<Adress>();
        store.DefineTable<Contractor>();
        store.DefineTable<Item>();
        store.DefineTable<ItemGroup>();
        store.DefineTable<Meeting>();
        store.DefineTable<Note>();
        store.DefineTable<Order>();

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

我得到了异常“在'Projekt.DataModel.Meeting''从'Adress'获取 Value 时出错 . ”

The thing is: It is really hard to work with this. Isn't there a simplier solution? I don't need at this moment nothing but synchronization of my database. Please remember that I have a tables that are connected by foreign key. Maybe I skip some worthy example or tutorial?

感谢你的帮助 .

1 回答

相关问题