Azure的移动服务应用的体系结构 [英] Architecture of Azure Mobile Services Application

查看:136
本文介绍了Azure的移动服务应用的体系结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图拼凑为Windows通用应用程序利用的Azure移动服务的体系结构。这是一个LOB应用程序,将需要处理100-250离线\\在线表。所以目前在服务端我从实体框架映射我的大部分表直接通过移动服务不支持嵌套复杂的对象。

I'm trying to piece together an architecture for a Windows Universal App leveraging Azure Mobile Services. It's a LOB app and will need to handle 100-250 offline\online tables. Currently Mobile Services doesn't support nested complex objects so on the service side I've mapped most of my tables straight through from entity framework.

我的问题是我是否应该使用一个单独的层重构的DTO的,或者我应该全部通过服务层和视图模型来这样做。我的主要问题是责任(大队)的分离和附加映射的性能开销。

The question I have is whether I should use a separate layer to reconstitute the DTO's or if i should be doing this all through the service layer and the view model. My main concerns are isolation of responsibility (large team) and the performance overhead from the additional mapping.

没有足够的信誉来这里添加图像的链接模型。

Didn't have the reputation to add an image here's the link to the model.

在这里输入的形象描述

的一个例子是附加地址的集合Person对象。我有三个DTO对象:一个是人一个是地址,一个是多对多的关系。如果我直接传送到视图模型映射我需要的寻址服务来查找地址为特定的人。

An example would be a Person object with a collection of addresses attached. I have three DTO objects: one for the person one for the address and one for the many to many relationship. If I'm mapping straight through to the view model i'd need an addressing service to lookup the address for a specific person.

如果我插入一个额外的示范图层我的服务返回此人模型的地址就可以了集合。这感觉有点不对劲,但...

If i insert an extra "Model" layer my service returns the Person Model with a Collection of address on it. It feels a bit wrong though...

推荐答案

正确的选择取决于你是怎么做的查询客户端上。在你的情况,你想要做的直接查询的地址,所以它可能是有帮助的客户端上的地址表。

The right choice depends on how you are doing querying on the client. In your case, you want to do querying on Address directly, so it is probably helpful to have an Address table on the client.

这样做的原因映射到DTO的是完全一样的对你说:有在Azure的移动服务对象之间的关系没有直接的支持。这是由设计,以确保一个简单的模型客户端和服务器之间的交互,但它可以意味着更多的设计时数据模型不涉及关系。

The reason for doing the mapping to DTOs is exactly as you said: there is no direct support for relationships between objects in Azure Mobile Services. This is by design to ensure a simple model for interacting between client and server, but it can mean more design when the data model does involve relationships.

在一般情况下,我们建议如下:

In general, we advise the following:


  1. 如果你有1:许多关系,那里是父母与子女之间的明确关系的所有权,它通常是最好的映射子对象到父。这也简化了在移动客户端创建新的子对象和联营与母公司的情况。离线同步协议单独发送的变化,所以对象必须组合在一起,如果他们需要的是一个原子操作。对于这样的一个例子,请参见 FieldEngineerLite样品

如果你有1:许多关系,对孩子进行查询并不重要对象直接,您可以映射在#1,或者创建为孩子单独的表控制器和管理与外键映射。

If you have 1:many relationships and it's not important to query on the child objects directly, you can either map as in #1, or create separate table controllers for the children and manage the mapping with foreign keys.

对于很多:很多关系,通常添加了太多的复杂性,直接暴露关系表。这里,考虑平坦化的对象ID入的对象之一。在你的榜样,客户DTO可以有地址ID列表,以及地址在客户端上自己的表。

For many:many relationships, it usually adds too much complexity to expose the relationship table directly. Here, consider flattening the object IDs into one of the objects. In your example, the Customer DTO could have a list of Address IDs, and the addresses are in their own table on the client.

如果你选择做选项#3,你的code需要确保所有相关地址被发送到客户端。你既可以一)映射到一个扁平的对象,然后在客户端解压,或b)条款添加到客户端或服务器端查询地址,使客户得到所有正确的数据。

If you choose to do option #3, your code needs to make sure that all the relevant addresses are sent down to the client. You could either a) map to a flattened object and then unpack on the client side, or b) add clauses to either the client or server side query for addresses so that the client gets all the right data.

在情况(b),你也应该确保该地址表更改Customer表上做查询之前拉低。情况(b)很容易实现,如果有,可以做到范围什么地址拉下的查询。

In case (b), you should also ensure that changes to the Address table are pulled down before doing queries on the Customer table. Case (b) is easy to implement if there is a query that can be done to scope what addresses to pull down.

例如,假设你正在建设一个顾客被分配到使用的应用程序的销售人员一个CRM应用程序。然后,你做对客户和地址的连接并获得只有那些属于通过登录的用户。

For instance, suppose you are building a CRM app where a customer is assigned to the salesperson using the app. Then, you do a join on Customer and Address and get only those Addresses that belong to a customer owned by the logged in user.

这篇关于Azure的移动服务应用的体系结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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