博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

讨论:
Using WCF for database operations

How to return datatable from a typed dataset using WCF service and Jun CTP ?

作为WCF的实践指导,这个原则在《Programming WCF Services》一书里也说明了:

Appendix C. WCF Coding Standard

C.4. Data Contracts

  1. Use the DataMemberAttribute on properties or read-only public members only.

  2. Avoid explicit XML serialization on your own types.

  3. When using the Order property, assign the same value to all members coming from the same level in the class hierarchy.

  4. Support IExtensibleDataObject on your data contracts.

  5. Avoid setting IgnoreExtensionDataObject on the ServiceBehavior and CallbackBehavior attributes to TRue. Keep the default of false.

  6. Do not mark delegates and events as data members.

  7. Do not pass .NET-specific types, such as Type, as operation parameters.

  8. Do not accept or return ADO.NET DataSet and DataTable (or their type-safe subclasses) from operations. Return a natural representation such as an array.

  9. Suppress the generation of a generic type parameter hash code and provide a legible type name instead.

  10. Avoid the /ct switch of SvcUtil or any other way of sharing an assembly type across the service boundary.


本着SOA的原则和传输效率之类的考虑,当然了,如果你的程序不跨平台(.NET---.NET)的话,DataSet之类的类型可以工作的很好。

BTW:《Programming WCF Services》这本书非常不错,除了对WCF技术的讲解之外还有大量的设计指导,不过目前只有英文版。园子里的Bruce Zhang正在翻译这本书。