Question about the generated CS

Jan 8, 2011 at 9:26 PM

Hi! I don't know if my problem is with linq to xsd or no but here we go:

I have a pretty complex XSD with multiple elements and child elements with custom types.

The LinqToXsd project did the job greatly to make me a CS file/class, and I can use it marvelously, but there is a Type, wich has the Add() function generated, but when I add like let's say 10 elements from that type in the resulting saved XML file (with the save(string path) function, one element, the last one will apear as first and last element, and my real first element is missing). I did a step by step debuging a,d I'm adding the elements in correct order with the add() function, and I still got this error. I know for sure it is okay, as there is a uniqe id in the add element function, and this uniqe id is in the first and last position in the file. Maybe it is an XSD error or is it something with the generator?


I'm writting here, maybe somebody else has met with this problem and can help me out.


Imagine the problem like this:

TypeA ta = new TypeA;

subElementA seA = new subElementA();

for (int i - 0; i <= 10; i++)

{ = i;






in the resulting xxx.xml file the number 10 will appear twice: as first and as last



Jan 10, 2011 at 5:07 PM

My mistake, sorry, I forgot to reinitialize the object after every use ... Sorry :) It can be deleted :)