如何仅将脏值从客户端数据传输对象传递到服务器端域模型
应用程序类型: 后端带有 RDBMS 的 3 层 Web 应用程序
开发平台
客户端:Silverlight 3/ WPF 服务:具有基本 Http 绑定的 WCF Web 服务
问题定义: 尝试开发一个具有客户端业务处理和传递给客户端的数据密集型对象的应用程序。在客户端屏幕中查看和编辑对象后,应将它们传递到服务器端的服务进行保存。问题是,由于数据量很大,我不想将整个对象再次传递回服务。例如:- 如果我有一个包含 10 行和每行 10 列的集合,并且只更新 2 列。我应该只能传递数据。
问题: 最佳方法是什么
这是一个好的做法吗?如果是的话,实现尝试过的解决方案的 我尝试了两种解决方案 1:让 setter 与事件委托进行更改通知 2:使用自定义数据类型
Application Type:
3-Tier web application with RDBMS at backend
Development Platform
Client : Silverlight 3/ WPF
Services: WCF web services with Basic Http binding
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. E.g:- If I have a collection of 10 rows and 10 columns for each row and only 2 columns are updated. 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 VS 自动生成的 WCF Web 服务,那么您几乎只能传输已知的类;因此,要传输较小的信息块,您将需要专门为此目的定义一些新类。我认为此类对象通常称为 DTO(数据传输对象)。因此,对于具有 10 x 10 矩阵的场景,您的 DTO 可能包含 {x, y, value} 三元组的列表。
如果您使用 REST Web 服务(并编写自己的 Web 服务),那么您可能完全避免使用 DTO 类,而只创建一个足以传达信息的 XML 模式;例如,具有以下形式的子元素的顶级元素:
然后,您的 REST 服务将必须完成增量更新服务器端数据库记录的工作。您可能需要为每种数据类型提供一个不同的 REST url。
HTH
比尔
If you're using WCF web services as automagically generated by VS then you're pretty much constrained to transmitting classes that are known; 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). So, for your scenario with the 10 x 10 matrix, your DTO would perhaps contain a list of {x, y, value} triples.
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; e.g., a top level element with subelements of the form:
Your REST service would then have to do the work of incrementally updating the server side database records. You'd probably need a distinct REST url for each data type.
HTH
Bill