Reputation: 1
I got problem with creating *.cs (C# Class) based on XML generated by serializing another C# class. XSD.exe throws following error:
- A column named 'Conditions' already belongs to this DataTable: cannot set a
nested table name to the same name.
My process looks like this:
The classes which are serialized to XML (in point 1) looks like this:
public class A
{
public A(){}
private List<string> _cond = new List<String>();
public List<string> Conditions
{
get{ return _cond; }
set{ _cond = value }
}
}
public class B:A
{
}
public class C:A
{
}
public class Data
{
B b = new B();
C c = new C();
/* ... ADD SOME DATA etc ... */
}
// After that I serialize to XML the "Data" class object
Can anyone suggest of workaround ?! This is clearly cause by inherided condition property
Upvotes: 0
Views: 1412
Reputation: 4314
You can change the way xsd.exe creates the output, n your case, it would make sense to use the /c(lasses) switch. Then, it will not create a dataset but "ordinary" classes instead.
There's also LinqToXsd, which has a fairly decent code generator.
Upvotes: 1