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 ~~~~~