【发布时间】:2015-01-13 08:16:07
【问题描述】:
我有一个普通的通用应用程序,没什么花哨的,很简单。
有一个重量超过 200KB(甚至可能是 20MB,记住这一点)的 SQLite 数据库,我想在 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' 获取值时出错。”
问题是:处理这个真的很难。没有更简单的解决方案吗?我现在什么都不需要,只需要同步我的数据库。请记住,我有一个通过外键连接的表。也许我跳过了一些有价值的示例或教程?
感谢您的所有帮助。
【问题讨论】:
标签: sqlite azure-mobile-services win-universal-app