Title: RE: [Mono-list] Automatic Binding of Variables to Parameters in ADO.NET
I had a look at this briefly last night. It looks like the xsd.exe tool does quite a bit more than I thought.
 
from the link:
http://msdn.microsoft.com/library/default.asp?url="">
 

Xsd.exe performs the following operations:

XDR to XSD
Generates an XML schema from an XML-Data-Reduced schema file. XDR is an early XML-based schema format.
XML to XSD
Generates an XML schema from an XML file.
XSD to DataSet
Generates common language runtime DataSet classes from an XSD schema file. The generated classes provide a rich object model for regular XML data.
XSD to Classes
Generates runtime classes from an XSD schema file. The generated classes can be used in conjunction with System.XML.Serialization.XMLSerializer to read and write XML code that follows the schema.
Classes to XSD
Generates an XML schema from a type or types in a runtime assembly file. The generated schema defines the XML format used by System.XML.Serialization.XMLSerializer.
Obviously the middle one is what we're talking about here.
 
I don't think the tool should be too difficult to write in itself, it's just a question of how complete are the required parts of the framework:
 
1) XML Schema support
2) Metadata in DataSets
3) CodeDom code generation
4) System.Data.TypedDataSetGenerator - this is the main missing component that does most of the work.
 
Piers.
 
-----Original Message-----
From: Daniel Morgan [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 27, 2003 5:33 AM
To: Piers Haken; Mono-List
Subject: RE: [Mono-list] Automatic Binding of Variables to Parameters in ADO.NET

Maybe that's what we need then - for someone to start working on the xsd.exe tool for creating type-safe DataSets.
 
What would be involved in creating this tool?
 
Any takers?
 
-----Original Message-----
From: Piers Haken [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 27, 2003 8:46 AM
To: Daniel Morgan; Mono-List
Subject: RE: [Mono-list] Automatic Binding of Variables to Parameters in ADO.NET

Microsoft ships a tool called xsd.exe that generates type-safe DataSets that do basically this. You give it an XML Schma for your table and it generates a source file for a class that drives from DataSet but which has typesafe accessors and events. It might be a little heavy-handed for what you want, though.

Piers.

> -----Original Message-----
> From: Daniel Morgan [mailto:[EMAIL PROTECTED]]
> Sent: Monday, January 27, 2003 4:52 AM
> To: Mono-List
> Subject: [Mono-list] Automatic Binding of Variables to
> Parameters in ADO.NET
>
>
> Hello,
>
> How could I automatically bind variables as paramters in SQL,
> execute the SQL, and get the results automatically.  Would
> this involve creating new attributes to handle this.  I know
> Glade# uses attributes to bind variables.
>
> Let's say we have a database table SOMETABLE with the following data:
>
> ANUM AMONEYVALUE ADATETIME           ABOOLEAN AVALUE
> ==== =========== =================== ======== ======
> 5    152.32      2002-12-31 12:34:56 False    9
> 6    36.45       2001-01-23 05:12:23 True     8
>
> Here is a struct that will contain the returned values.
>
> public struct MyStruct
> {
>   int someNumber;
>   double someMonetaryValue;
>   DateTime someDataTime;
>   bool someBoolean;
> }
>
> Here is the sample code that demonstrates what I am asking.
>
> [SomeMagicMethodParameterDataBind("someValue"]
> public MyStruct GetData (IDbConnection dbcon, int someValue)
> {
>       [SomeMagicDataBind("mystruct"]
>       MyStruct mystruct;
>
>       string sql =
>          "SELECT aNum, aMoneyValue, " +
>          "       aDateTime, aBoolean " +
>          "FROM sometable " +
>          "WHERE :someValue " +
>          "INTO mystruct.someNumber, mystruct.someMonetaryValue, " +
>          "     mystruct.someDateTime, mystruct.someBoolean";
>
>      SomeMagicalClass magic = new SomeMagicalClass(dbcon, sql);
>      magic.ExecuteSQL();
>
>      return mystruct;
> }
>
> If I call GetData() with someValue set to 9, I should get a
> MyStruct struct that has the following resuls:
>
> MyStrcut mystruct = GetData(dbcon, 9);
>
> // expected results
> mystruct.someNumber = 5
> mystruct.someMonetaryValue = 152.32
> mystruct.someDateTime = "2002-12-31 12:34:56"
> mystruct.someBoolean = false
>
> This is what I am interested in having.  Now, how do I get
> this?  I'm sure I would need to use reflection heavily and
> attributes. There would be parsing of SQL for parameters,
> create parameters based on the parameters in the SQL, update
> the parameters with information from variables currently in
> scope that match the name of the parameter, set the value of
> any input or input/output parameters from the variable that
> have been bounded earlier, execute the SQL, set the values of
> any return, output, or input/output variables based on the
> results in the parameters.
>
> Any ideas?
>
> If you ever used RAD programming languages like Delphi,
> Centura/Gupta SQL Windows, PowerBuilder, or Visual Basic, you
> would understand how powerful this can be for database applications.
>
> Thanks Daniel
>
> _______________________________________________
> Mono-list maillist  -  [EMAIL PROTECTED]
> http://lists.ximian.com/mailman/listinfo/mono-list
>

Reply via email to