CodeSmith Community
Your Code. Your Way. Faster!

Strong typed dataset schema (xsd)

Latest post 10-09-2007 9:56 PM by gbeltrao. 12 replies.
  • 01-07-2004 4:05 PM

    • Mihies
    • Top 50 Contributor
    • Joined on 01-11-2003
    • Slovenia, Nova Gorica
    • Posts 80
    • Points 2,615

    Strong typed dataset schema (xsd)

    Hi guys,
     
    This template generates strong typed dataset schema (xsd) for selected tables.
     
    Requirements: CodeSmith beta 2.5.9 or later
     
    Follow the link below,
     
    Comments are welcome.
    Miha Markic [MVP C#], RIGHTHAND .Net consulting and software development
    • Post Points: 435
  • 01-22-2004 10:33 PM In reply to

    • Erick
    • Top 100 Contributor
    • Joined on 08-15-2003
    • Posts 44
    • Points 1,035

    RE: Strong typed dataset schema (xsd)

    Miha,
    Good stuff! I'm planning on using this in some of my projects. Does the Guid type work correctly with the MSDataSetGenerator? I noticed that VS.NET, when it pulls in a Guid, does
    <xs:element name="field" msdata:DataType="System.Guid, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" />
    Which I'd like to do. Also, I was going to add code to generate unique constraints, on both the primary keys, and any indexes on the table. This works with ADO.NET Improved DataSet Generator (which I'm doing dev on). Are you doing any more work on your template? If so, we should make sure we aren't doing the same work twice. :-)
    Erick
    Miha Markic said...
    Hi guys,
     
    This template generates strong typed dataset schema (xsd) for selected tables.
     
    Requirements: CodeSmith beta 2.5.9 or later
     
    Follow the link below,
     
    Comments are welcome.

    Post Edited (Erick) : 1/22/2004 10:34:02 PM GMT

    • Post Points: 5
  • 01-23-2004 1:17 PM In reply to

    • Mihies
    • Top 50 Contributor
    • Joined on 01-11-2003
    • Slovenia, Nova Gorica
    • Posts 80
    • Points 2,615

    RE: Strong typed dataset schema (xsd)

    Hi Erick,

    Currently I am idle on this - no comments were made so far.
    I am not sure what are you reffering to with ADO.NET Improved DataSet Generator.
    Are you upgrading my template?
    If so, I would be very glad for your contribution and ideas.

    I am not sure on GUIDs as I've never used them. Will have to check
    Miha Markic [MVP C#], RIGHTHAND .Net consulting and software development
    • Post Points: 5
  • 02-28-2004 12:47 AM In reply to

    • Erick
    • Top 100 Contributor
    • Joined on 08-15-2003
    • Posts 44
    • Points 1,035

    RE: Strong typed dataset schema (xsd)

    Miha,
    The improved typed dataset generator is part of the ADO.NET PowerToys project, and is basically a replacement for the xsd.exe application in .NET. It generates Typed DataSets that are drop in compatible with the MS Typed DataSets, but also include additional functionality. I'm working a new version right now, but the current version works pretty well.
    As for the template, I've made some changes. First, I added an include related property that automatically gets dependant tables and adds them to the XSD. I also set up the foreign key relationships between all the tables, so the XSD will fully reflect the database. Finally, in the case of text columns of finite length (char/varchar), I added a type for the XSD that limits the length of column (which is supported by both xsd.exe and the ADO.NET tool). In addition, I fixed up the Guid problem, so it generates correctly now. I've attached the template to this message, but there might be some problems with it. If so, let me know!
     
    Thanks,
    Erick
     
    (edit: there was a bug in the template which I fixed)

    Post Edited (Erick) : 2/28/2004 1:38:19 AM GMT

    • Post Points: 5
  • 03-23-2004 2:44 PM In reply to

    RE: Strong typed dataset schema (xsd)

    Miha, Erick - great template!

    Erick - I assume you're the ErickT on the GotDotNet workspace... You say you are working on a new version of the xsd.exe replacement - what is the status of this? I'd be very interested in the new version and any CS related templates.

    Thanks,
    Oskar
    Thanks,
    • Post Points: 5
  • 03-23-2004 9:40 PM In reply to

    • Erick
    • Top 100 Contributor
    • Joined on 08-15-2003
    • Posts 44
    • Points 1,035

    RE: Strong typed dataset schema (xsd)

    Oskar,
     
    I am the same ErickT that is in the workspace. The xsd.exe replacement is working, and has a number of improvements over the typed datasets that xsd.exe generates. If you go ahead and download the latest version, you can use it as a drop in replacement for xsd.exe.
     
    I've been spending a lot of time on this template, to allow it to support a combination of views and tables, as well as encode information into the xsd relating the source (view/table, DB object name, etc). I have a DAL generator that I'm using which uses this info to create CRUD methods that can use the dataset, even if it's been changed from the DB (renames, etc). I'll be posting this stuff up here when it gets closer to being finished...
     
    Thanks for the complement,
    Erick
    • Post Points: 5
  • 03-23-2004 10:05 PM In reply to

    • ejsmith
    • Top 10 Contributor
    • Joined on 12-27-2002
    • Dallas, TX USA
    • Posts 2,204
    • Points 922,455

    RE: Strong typed dataset schema (xsd)

    Erick,

    I was planning to create an XSD.exe replacement for the CodeSmith engine to allow XML to be used as a template property more easily. I guess I should check out what you have done so far.

    Thanks,
    Eric J. Smith

    Eric J. Smith
    CodeSmith Tools, LLC
    Chief Software Architect

    • Post Points: 5
  • 03-23-2004 10:10 PM In reply to

    • Erick
    • Top 100 Contributor
    • Joined on 08-15-2003
    • Posts 44
    • Points 1,035

    RE: Strong typed dataset schema (xsd)

    Eric,

    I think creating an xsd.exe replacement in codesmith isn't the best use of time. There's been a great of effort put into the ADO PowerToys project, and I'm sure we could figure out a way to integrate the two together.

    As far as using XML as a data source for a template, what I've done so far is created a custom editor for selecting an XSD, and I then load the xsd as a schema into a generic (untyped) dataset. I can then write templates based on that structure, including keys, relations, etc. Is this the type of thing you are thinking about?

    Erick

    Post Edited (Erick) : 3/23/2004 10:10:44 PM GMT

    • Post Points: 5
  • 03-23-2004 10:58 PM In reply to

    • ejsmith
    • Top 10 Contributor
    • Joined on 12-27-2002
    • Dallas, TX USA
    • Posts 2,204
    • Points 922,455

    RE: Strong typed dataset schema (xsd)

    Erick,

    The end goal is to be able to do something like this:

    <%@ XmlProperty Name="MyXml" Schema="MyXml.xsd" %>

    This would dynamically build a strongly typed object model for this schema and allow the user to select an XML document instance to populate that object model. You would then be able to build your templates against a rich fully typed object model. One of the issues I've discovered so far is that this object model can't be a derivative of DataSet because of a limitation in the .NET designer support. (It seems as if any custom editor attribute that is applied to a DataSet derived class is ignored.)

    I'm not sure how we would work something out with the work that you have done since my product is closed source. I will take a look at what you guys have been working on anyway and see if I can somehow use it without including it.

    Thanks,
    Eric J. Smith

    Eric J. Smith
    CodeSmith Tools, LLC
    Chief Software Architect

    • Post Points: 5
  • 03-24-2004 12:00 AM In reply to

    • Erick
    • Top 100 Contributor
    • Joined on 08-15-2003
    • Posts 44
    • Points 1,035

    RE: Strong typed dataset schema (xsd)

    Eric,

    I think see what you're saying, but I don't think you need to make it that complex. If you use the LoadSchema method on a DataSet object, it will be exactly the same as the DataSet generated by xsd.exe (or the other gen tool) with the exception on the strongly typed methods/properties. For doing template development, you're going to want to iterate over tables and columns, so the strong typing doesn't help.

    Are you working on a non DataSet system? If so, then I'm off base. If you're working on a DataSet based system, it can be made to work as derived from the DataSet, even in the designer, but it takes some work. Feel free to check out the source for the other generator. Can you call into an external DLL from your code? If so, I think you should be able to use the open source portion.

    Here is what I have at the start of my templates that use the TDS.

    DataSet ds;
    string loc;

    [Editor(typeof(CodeSmithDataSet.DataSetPicker), typeof(System.Drawing.Design.UITypeEditor))]
    public string XsdLocation {
    get {
    return loc;
    }
    set {
    loc = value;
    ds = new DataSet();
    ds.ReadXmlSchema(loc);
    }
    }

    The picker is a simple file browse dialog right now, where the user picks the xsd file. I then use the generated DataSet as the basis for all my templates. It could be better integrated, but is this similar to what you're doing?

    Erick
    • Post Points: 5
  • 06-10-2004 6:50 AM In reply to

    RE: Strong typed dataset schema (xsd)

    The ignored custom editor, maybe its your implementation of your PropertyGrid. Have a look at, http://www.dotnet247.com/247reference/msgs/42/210909.aspx
    I have found the TypeConverters and UIEditors do not load if the PropertyGrid cannot resolve their assembly.
     
    This is interesting as I have written a DataSet generator for us to use in-house. I suppose here are a few pointers to things that helped.
     
    * Used the PowerToys xsd code generator to easily add inheritable DataTables.
    * I have found issues with writing xml schemas from DataSets. They do not correctly handle foreign keys and their cascade rules, and use unique keys, instead of schema keys. Using the decoder from XSDEditor by Marc Clifton, I found I could doctor the DataSets xsd and correct errors
    * derive all database access using generic interfaces (e.g. IDbCommand, IDbDataAdapter, IDbConnection, ITransaction, IDataReader), the same code can be used for any of the data providers ODBC, SqlClient, Ole or proprietry
    * Generate your code with CodeDom, gives you c#, vb, J#, mcpp, javascript outputs with a click of the button
     
    The generator saves us hours and hours of work.
     
    Ray Gilbert
     
    • Post Points: 5
  • 06-10-2004 5:39 PM In reply to

    • Erick
    • Top 100 Contributor
    • Joined on 08-15-2003
    • Posts 44
    • Points 1,035

    RE: Strong typed dataset schema (xsd)

    What is the status of your DataSet generator? I'd love to take a look at it.

    I'm working ont he PowerToys xsd code generator; I'd be interested in knowing if you modified it.

    Erick
    • Post Points: 5
  • 06-11-2004 1:54 AM In reply to

    RE: Strong typed dataset schema (xsd)

    Eric,
     
    Where can I put it, to show you. The binaries are about 201K zipped
     
    Ray
    • Post Points: 5
  • 06-11-2004 6:19 PM In reply to

    • Erick
    • Top 100 Contributor
    • Joined on 08-15-2003
    • Posts 44
    • Points 1,035

    RE: Strong typed dataset schema (xsd)

    Ray,

    You can email to me at ethompson@nbr.org.

    Thanks,
    Erick
    • Post Points: 5
  • 12-09-2004 9:09 PM In reply to

    • swmolen
    • Not Ranked
    • Joined on 12-07-2004
    • Posts 5
    • Points 85

    RE: Strong typed dataset schema (xsd)

    Mmmm. I would love to see that new codesmith template that takes advantage of typed datasets. I wrote a template to aid me in some of the coding for my facade/dac work (We use typed datasets a lot) and my next big project was going to be to write a codesmith template for auto-generation of the whole shibang with typed datasets in mind.
     
    Erick, If you could send me that work in progress of your DAL generator it would greatly help me to see whether I should write one myself or if yours could work for me.
     
     
    Here is the link to my current junk templates that I have.
     
     
    • Post Points: 5
Page 1 of 2 (18 items) 1 2 Next > | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems