March 8, 2008

The other day I tried to implement LINQ To XSD 0.1 alpha into my production code. I was trying to achieve a strongly typed xml development experience. I failed and gave up. I am not sure where I went wrong but there isn’t really too much clear and simple documentation out there on how to integrate it into your project.

Ofcourse,The first thing I did was hit LINQ To XSD in google and click on the first link. After reading some fairly easy instructions I download the necessary msi packages, install them and ‘infer a schema’ from my XML. Here is where I believe I’m missing a step. It appears all the examples I am looking at do something like this

var xmlSource = XDocument.load(uri);

var xmlTree = from x in xmlSource

                     select xmlSource.SomeStronglyTypedProperty;

and hey presto it all works. Well, for me ofcourse, I don’t get my strongly typed properties. It appears I’m missing a step where I have to do something in visual studio to use the strongly typed class rather than the late bound one.

Also. Some questionable usability points about the XDocument class. First of all, the nitty gritty. Why does the method XDocument.Load’s parameter take a string when it’s a URI? I believe URI would be an appropriate data type unless there is a reason for it? Secondly, in my application I have 3 projects. A database project, a “core” business class project and a front end asp.net project. When trying to work with XML and XSD files I created my XML file called FlashBanner.xml in my core project and also saved the inferred schema FlashBanner.xsd next to it in the core project. But the problem is I don’t have any easy way to reference anything in the core through URI. Rather an overload of XDocument.Load(string FilePath) would be nice. As a quick work around I ended up creating an xml folder in my asp.net project but I would much prefer to keep files like that in my core project.

Other then the fact that I couldn’t get it to work and that there doesn’t appear to be any easily found and read information on how to use it, Thanks to Visual Studio’s automatic “Infer Schema” doing all the work, LINQ To XSD looks like a technology that I would be using absolutely anywhere and everywhere.


Technorati Tags: , , , ,


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: