具有视图或存储过程的Azure移动应用中的脱机数据同步 [英] Offline Data Sync in Azure Mobile Apps with Views or Stored Procedure

查看:83
本文介绍了具有视图或存储过程的Azure移动应用中的脱机数据同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经创建了Xamarin Forms应用程序,目前仅在Android上运行.后端是.Net Azure移动应用服务

We have created a Xamarin Forms application and currently just running on Android. Backend is .Net Azure Mobile Apps service

我从文章理解表示离线数据同步仅适用于"/表" 端点. (至少那是我的理解)

I understand from the articles that offline data sync only works with "/tables" endpoint. (at least thats what I understood)

但是我的API公开了来自联合查询(实体关系)的数据,以及一些来自存储过程的数据.这是否意味着这些不适用于当前的SDK? 我有什么选择?

But my API exposes data from joined queries (entity relationship), and some from stored procedures. Does it mean these can't apply to current SDK? What are my options?

我是否公开表并处理客户端中联接的业务逻辑?

Do I expose tables and handle the business logic for the joins in client end?

推荐答案

对于关系和离线同步,您有两个选择.

You have a couple of options for relationships and offline sync.

1)创建带有触发器的视图.插入,更新或删除条目时-对后端表执行正确的操作".视图将自动更新.您的EF模型应引用该视图.由于您只处理一个表(因为它实际上是一个视图),因此该操作完全脱机.这里有SQL的复杂性,许多关系无法用这种方式表示.

1) Create a view with triggers. When an entry is inserted, updated or deleted - do "the right thing" for your backend tables. The view will automatically be updated. Your EF model should reference the view. This works completely offline since you are only dealing with one table (because it's actually a view). There is SQL complexity here and a lot of relationships can't be represented this way.

2)将各个表用作只读"-张贴/放入/删除自定义API进行插入,更新和删除,以便保留数据库的参照完整性.这意味着您的数据可以脱机使用,但除非在线,否则无法更新数据库

2) Use individual tables as "read-only" - post/put/delete to a custom API to do the inserts, updates and deletes so that the referential integrity of your database is preserved. This means your data is available offline but you can't update the database unless you are online

3)从数据库中删除关系,然后在客户端上执行联接等.这给您的客户带来了负担.这也意味着您的后端需要强制执行完整性,因为您不知道这是您的客户端访问后端.可能不是最好的主意.

3) Remove the relationships from your database and perform the joins, etc. on the client instead. This puts the onus on your client. It also means your backend needs to enforce the integrity since you won't know that it's your client accessing the backend. Probably not the best idea.

4)规范化数据并重组数据库.

4) Denormalize your data and restructure your database.

我确定有人会提出其他想法.还要查看我关于该主题的博客文章: https://shellmonger.com/2016/05/27/30-days-of-zumo-v2-azure-mobile-apps-day-26-relationship-advice/

I'm sure someone will come up with other ideas. Check out my blog post on the subject as well: https://shellmonger.com/2016/05/27/30-days-of-zumo-v2-azure-mobile-apps-day-26-relationship-advice/

选择哪种代码取决于要编写的代码量,在T-SQL中的使用感觉以及实际数据模型的外观.所有这些都需要权衡.

Which one you choose depends on how much code you want to write, how comfortable you feel in T-SQL and what the actual data model looks like. There are trade offs with all of them.

这篇关于具有视图或存储过程的Azure移动应用中的脱机数据同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆