How to generate a circular reference error when using linqtosql in a WebService in a parent-child table with a one-to-many relationship requires the tolist to output the generic type !)

Source: Internet
Author: User

When creating a website, there are two tables, which are a one-to-many relationship.

Then, a LINQ to SQL class is automatically generated using the generator.

Because the sub-table also has a parent table attribute, when the query result is tolist

WebService output produces

System. invalidoperationexception: an error occurs when an XML document is generated.

The reason is that the sub-table has a parent table attribute, which causes circular reference.

Finally, I found a solution on a Russian website, that is, when the designer generates a LINQ class, it changes the relevant attribute settings.

The table is as follows:

Click the link arrow in the middle.

Modify in Property Manager

Change the access permission in the parent attribute to friend.

Then modify the attributes of the LINQ to SQL class.

Change serialization mode to unidirectional

In this way, you can ~~~~~

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.