Serialization of WCF + nhib.pdf

Source: Internet
Author: User

If you encounter the same problem, find some information on the webpage and record it first!

 

Server nhibbench 3.0 + WCF. When the client calls the API, if the query involves Association queries, either one-to-many or multiple-to-one

Error: unable to read data from the transmission connection: the remote host forces an existing connection to be closed. It is difficult to identify the error. At the beginning, the query times out and the problem persists after the configuration file is modified.

The server console prints SQL statements and shows that the query is complete. Most of the queries on the Internet are about serialization. Modify the maximum serialization value in the configuration file, flip the blog of several foreigners, and rewrite datacontractserializeroperationbehavior, the English language is too bad to copy the example. However, after a comprehensive analysis, we finally solved the problem. The second query takes a long time, because the existing project is generated using the Nhibernate module of codesmith.CodeThe templates used for self-writing examples are different. If the result example is successful and fails to be put into the project, the generated client code is compared before being released.

Solution:

1. Multiple-to-one, lazy = "false"

2. for one to multiple objects, the bag ing type in the object configuration file is bag, and the attribute corresponding to the object class must be a set of strong types such as ilist <user>, otherwise, the corresponding property in the code generated by the client is ilist <Object>.

3. Add isreference = true to object class serialization configuration, for example, [datacontract (isreference = true)].

I just got in touch with WCF, and it's time to get started.

 

Transferred from:

Http://www.oschina.net/question/25945_20177

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.