首页 文章

使用Azure移动应用程序服务的Xamarin移动客户端中的数据库

提问于
浏览
2

我正在构建一个Xamarin移动应用程序,使用Azure移动应用程序服务进行离线同步 .

A. Xamarin(移动客户端):
Xamarin的文档展示了如何构建应用程序和本地数据库(使用 sqlite-net ORM) . 模型使用各种属性进行注释 .

B. Azure移动应用服务(服务器):
Azure 's docs show how to define models in the mobile app (without sqlite-net), and define similar models on the server app (using a customised Entity Framework). The client models use different attributes, and the server models don' t使用任何属性并派生自 EntityData .

但是,客户端有两个数据库 - “真正的”(A)和Azure API(B)中的数据库 .

Am I supposed to only implement (B)?

这意味着,(A)只有我想要一个本地数据库,而我根本不需要 sqlite-net ORM?

1 回答

  • 3

    如果您正在使用Offline Data Sync in Azure Mobile Apps,那么您不应该执行A,因为已经为您创建了本地数据库作为脱机同步功能的一部分 . 您将B作为C#ASP.NET服务器编程模型的一部分,或者您可以将Easy Tables与Node.js后端一起使用 .

    如果您根本不想要 Cloud 连接应用程序并且数据仅在本地存储(即,不与服务脱机同步),则仅执行A.

    或者,如果您想要 sqlite-net 提供的ORM(而不仅仅是Azure Mobile客户端SDK中的基本查询和CRUD),则可以基于 sqlite-net 定义自定义本地存储 . 为此,请创建IMobileServiceLocalStore的实现 . Mobile Apps客户端SDK是开源的,因此您可以使用MobileServiceSQLiteStore作为起点 .

相关问题