Using LinqToXSD, how to get the objects in a xml without casting?

398 views Asked by At

I'm using this technology to manage my XML files as Databases. When I do this, normally I created the classes in a library and using XSD.exe I can get my XSD.

Then, with LinqToXSD and my new XSD generated, I can access to the data. This is my first class which should be in my program.

public class Foo
{
    string FirstName
    string LastName
}

And to access the data I used this namespace

urn.foo

And I realized, that they are two different classes, I mean I need to convert this class (urn.foo from XSD) into real Foo (the first one). So, I have two different classes, and I want to have just one!

1

There are 1 answers

0
svick On BEST ANSWER

xsd.exe generates partial classes. So, if you put your “real” Foo into the same namespace in the same assembly as the generated one, make it partial too and remove any duplicated parts, then you will have only one Foo type.