Stored procedures provide the ability to perform some action
against a database and have some advantages to querying data from an
application. First and foremost, it reduces the amount of redundancy and has a
performance gain when multiple calls are executed. In addition, it does not
have any hindrances when used with the .NET 2.0 Framework, as stored procedures
can be used directly in the ASP.NET 2.0 data source controls.
But coding those stored procedures can be a tedious task,
especially when many of the stored procedures work the same way. They read,
insert, delete, and update rows in the database using the same or similar
structure. When reading data, usually all of the fields are read from, and so
no specialization is usually needed. When inserting data, usually all of the
fields are inserted and all of the same fields, except for the key value, are
updated in an update stored procedure. Deletions usually occur by specifying
the key field only, but that is not necessarily true. Sometimes the
create/update stored procedure is lumped into one. This is true in
business-object applications, but may be less true in data-driven applications.
This article will show you how a generator for stored
procedures could be created using the new Windows Presentation Framework (WPF)
features of .NET 3.0.