简体   繁体   English

如何仅将脏值从客户端数据传输对象传递到服务器端域模型

[英]How to pass dirty values only from client side data transfer object to server side domain model

Application Type: 3-Tier web application with RDBMS at backend 应用程序类型:后端带有RDBMS的3层Web应用程序

Development Platform 开发平台

Client : Silverlight 3/ WPF Services: WCF web services with Basic Http binding 客户端:Silverlight 3 / WPF服务:具有基本Http绑定的WCF Web服务

Problem Definition: Trying to develop a application that has a client side business handling and data intensive objects being passed to client. 问题定义:尝试开发一个具有客户端业务处理和将数据密集型对象传递给客户端的应用程序。 Once the objects are viewed and edited in client screen they should be passed to services on server side for save. 在客户端屏幕上查看和编辑对象后,应将它们传递到服务器端的服务以进行保存。 The issue being since that data is in sizable amount I dont want to pass the entire object back again to the services. 问题是由于该数据量很大,因此我不想将整个对象再次传递回服务。 Eg:- If I have a collection of 10 rows and 10 columns for each row and only 2 columns are updated. 例如:-如果我有10行和每行10列的集合,并且仅更新2列。 I should be able to pas only the data. 我应该只能粘贴数据。

Question: Is this a good practise and if yes whats the best way to achieve 问题:这是一种好习惯吗?如果是,那么实现这一目标的最佳方法是什么?

Tried out solutions I have tried two solutions 1: Have setters with event delegate that do change notification 2: Use custom data type 尝试了解决方案我尝试了两种解决方案1:让带有事件委托的setter进行更改通知2:使用自定义数据类型

If you're using WCF web services as automagically generated by VS then you're pretty much constrained to transmitting classes that are known; 如果您使用的是由VS自动生成的WCF Web服务,那么您就不得不限制传输已知的类; thus to transmit smaller chunks of info you will need to define some new classes specifically for that purpose. 因此,要传输较小的信息块,您将需要专门为此定义一些新类。 Such objects are I believe commonly called DTO (Data Transfer Objects). 我相信这类对象通常被称为DTO(数据传输对象)。 So, for your scenario with the 10 x 10 matrix, your DTO would perhaps contain a list of {x, y, value} triples. 因此,对于使用10 x 10矩阵的情况,您的DTO可能包含{x,y,value}三元组的列表。

If you're using a REST web service (and composing your own) then you might avoid the DTO classes entirely and just create an XML schema that is adequate to convey the info; 如果您使用的是REST Web服务(并由您自己组成),则可以完全避免使用DTO类,而只需创建一个足以传达信息的XML模式即可。 eg, a top level element with subelements of the form: 例如,具有以下形式的子元素的顶级元素:

<Deltas>
  <Delta x="3" y="9"> ...value subelementgoes here </Delta>
  ... more Delta elements
</Deltas>

Your REST service would then have to do the work of incrementally updating the server side database records. 然后,您的REST服务必须完成增量更新服务器端数据库记录的工作。 You'd probably need a distinct REST url for each data type. 对于每种数据类型,您可能需要一个不同的REST URL。

HTH 高温超导

Bill 法案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM