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

Adam Treat manyoso@yahoo.com
Mon, 27 Jan 2003 05:54:16 -0800 (PST)


I imagine this is an ideal problem for Microsoft's new XML language/tool.  AFAIK, rumor has it the
new XML language was created to simplify the mapping between SQL database applications and
strongly typed XML representations.

--- Daniel Morgan <danmorg@sc.rr.com> wrote:
> 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?
> 
> 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
>   >
> 
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com