Why returning dataset or data table from WCF service is not a good practice? What are the Alternatives?

前端 未结 3 1661
萌比男神i
萌比男神i 2020-12-06 05:38

I am working on University Management System on which I am using a WCF service and in the service I am using DataTables and DataSets for getting data from database and datab

3条回答
  •  星月不相逢
    2020-12-06 06:15

    Returning data sets from web services is not typically considered a “good practice”. The issues have been documented thoroughly in the following links:

    http://msdn.microsoft.com/en-us/magazine/cc163751.aspx
    http://www.4guysfromrolla.com/articles/051805-1.aspx
    http://msdn.microsoft.com/en-us/magazine/cc188755.aspx

    In summary, the biggest issues with returning DataSet objects from web services seem to involve serialization performance, non-.net interoperability. In addition, the generic, polymorphic nature of the DataSet generally high the data structure until runtime, as such, the WSDL definition does not provide a complete description of the method signature. As with any design decision, however, you need to weigh the costs vs the benefits and determine the best fit given your specific goals and constraints.

    In terms of alternatives, you could consider using a generic collection (e.g. List) or maybe even consider some architecture revisions to permit the use of ODATA.

    The following links provide some good background reference for returning entities via web services. http://msdn.microsoft.com/en-us/library/orm-9780596520281-01-14.aspx http://www.codeproject.com/Articles/127395/Implementing-a-WCF-Service-with-Entity-Framework http://msdn.microsoft.com/en-us/data/hh237663.aspx

提交回复
热议问题