[Mono-list] Automatic Binding of Variables to Parameters in ADO.NET

A Rafael D Teixeira rafaelteixeirabr@hotmail.com
Mon, 27 Jan 2003 18:30:46 -0200


>RE: [Mono-list] Automatic Binding of Variables to Parameters in 
>ADO.NETMaybe
>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?

XSD is, in truth, four tools in one.

Because it converts:
- schema to classes (source-form)
- classes (binary-form) to schema
- schema to typed-datasets (source form) (that is what Piers was talking 
about)
- xml to schemas

Probably itīs better to split it in phases, and not trying to have the full 
tool as the first deliverable...

BTW, Datasets implement an interface IBindingList or something like that, 
I'm not sure. This interface serves as an enumerator of bindable fields for 
SWF/ASP.NET controls. We should look at those for glade too. Any class 
derived from Component that implements such interface is bindable to 
SWF/ASP.NET controls, even if not ADO.NET based...

Happy Hackings,

Rafael Teixeira
Brazilian Polymath
Mono, MonoQLE Hacker



>From: "Daniel Morgan" <danmorg@sc.rr.com>
>
>Any takers?
>
>-----Original Message-----
>From: Piers Haken [mailto:piersh@friskit.com]
>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:danmorg@sc.rr.com]
>   > 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  -  Mono-list@lists.ximian.com
>   > http://lists.ximian.com/mailman/listinfo/mono-list
>   >
>

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963