Android移动应用中来自1:n关系的Azure离线数据同步 [英] Azure offline sync of data from 1:n relationship in Android mobile app

查看:45
本文介绍了Android移动应用中来自1:n关系的Azure离线数据同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的Android应用(Java)中启用Azure离线同步.我在云同步Web服务(C#)中添加了与1:n关系的模型,如

I'm trying to enable Azure offline sync in my Android app (Java). I added models with 1:n relationship to my cloud sync web service (C#) like in this article:

public class TodoItem : EntityData
{
    public string Text { get; set; }
    public virtual ICollection<Item> Items { get; set; }
}

但是如何在客户端应用程序的Java代码中设置1:n关系呢?

But how can I set 1:n relationship in Java code in my client application?

public class TodoItem {
    @com.google.gson.annotations.SerializedName("id")
    private String mId;
    @com.google.gson.annotations.SerializedName("text")
    private String mText; 
}

是否可以在Azure脱机同步中实现表关系(服务器端或客户端)?有人做到了吗?

Is it possible to implement table relationships (either server side or client side) in Azure offline sync? Did someone make it?

如果是,MobileServiceSyncContext如何在推送过程中解析表的顺序?我的意思是,如果服务器端(Azure移动应用程序)支持关系,而客户端端(Android应用程序)-不支持关系,并且如果MobileServiceSyncContext首先推送表Item,则服务器端将发生数据一致性错误.

If yes, how MobileServiceSyncContext resolves order of tables during push process? I mean, if server side (Azure mobile app) supports relationship, and client side (Android application) - doesn't support, and if MobileServiceSyncContext pushes table Item first, data consistency error will occured on server side.

如果Azure移动应用程序根本不支持关系(服务器端或客户端端),那意味着我的存储中不包含相关表,那只是一堆不相关的表?

And if Azure Mobile Apps does not support relationships at all (neither server side or client side), that means that my storage doesn't contain related tables, it's just a heap of unrelated tables?

推荐答案

对于Azure Mobile Apps上的android客户端,您的方案属于将具有复杂属性或数组属性的对象存储到表中,请参阅小节如何:将对象或数组属性存储到

For android client on Azure Mobile Apps, your scenario is belong to store an object with complex properties or array property into a table, please refer to the subsection How to: Store an object or array property into a table of the section How to: Customize the client from the Azure offical document to do it.

作为参考,有一个博客介绍怎么做.

As reference, there is a blog which introduce how to do it.

这篇关于Android移动应用中来自1:n关系的Azure离线数据同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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