views:

1855

answers:

4

Is there a utility out there that will create VB.NET classes from a Dataset.xsd file? And I don't mean like the XSD.exe utility does - all that does is convert the XML of an XSD file into classes in a .vb - it doesn't append any "extended" functionality.

I'm basically looking for something that will generate the beginnings of a business layer from the XSD file. Like creating a partial class for each datatable, then create a property for each of the datatable's columns as the right datatype and finally the basically CRUD methods as well.

This is something I have to do manually over and over again for each project. (I do lots of little projects and use VistaDB so I can't use Linq-To-SQL - wish I could)

+1  A: 

I know this doesn't strictly answer the question, but it looks like VistaDB either does, or will soon, have a provider that can be used with Linq to Entities - see here

Paul Nearney
Yes, I've seen that but L2E seems a little overkill for the size of my apps. I haven't ruled it out though. Any other ideas while I'm waiting for that?
EdenMachine
Again, probably doesn't strictly answer the question as i'm not sure about XSD functionality, but i'm sure you could create CodeSmith templates to work against your databases - http://www.codesmithtools.com/
Paul Nearney
Yeah, I'm looking into MyGeneration (similar to CodeSmithTools) right now actually. Thanks!
EdenMachine
+1  A: 

Liquid studio XML Data Binder looks like it does what you want and has a 30 day trial you can download.

Joshua
it's close but it looks like it's mostly for generated RSS feeds from a database or something. Thanks though!
EdenMachine
+2  A: 

Try taking a look at T4 and Code Generation tools in Visual Studio. It's like "writing code that writes code", and it's incredibly powerful.

A great video, really an "aha experience" for me http://www.pnpguidance.net/Screencast/T4TemplatesVisualStudioCodeGenerationScreencast.aspx

MSDN: http://msdn.microsoft.com/en-us/library/bb126445.aspx

Rob Conery has written an intro: http://blog.wekeroad.com/blog/make-visual-studio-generate-your-repository/

... and so did Scott Hanselman: http://www.hanselman.com/blog/T4TextTemplateTransformationToolkitCodeGenerationBestKeptVisualStudioSecret.aspx

I understand it's probably not exactly what you're hoping for, but when you want more flexibility and NOT having to write the same code over and over again, it really sounds like T4 could be a solution.

You'll write a template, that analyses your XSD file and generates the vb files directly in your project.

Jakob Gade
A: 

I think that xsd.exe will do what you need it to. Here's and example to convert purchaseorder.xsd to a vb class in the Purchasing namespace:

xsd.exe -c -l:vb -n:Purchasing purchaseorder.xsd

Type xsd.exe /? from a visual studio command prompt to get all of the options.

You can find more info here.

Paul G