Geeks With Blogs
Scott Kuhl Warning: I may have no idea what I am talking about!

Some tasks are just too complicated for dynamic query building and/or require a greater level of control.  To handle this, SubSonic supports stored procedures.  Each stored procedure will produce an equivalent static method in the class defined in the configuration file.  By default this is SPs.  Each method will have one parameter for each stored procedure parameter and return a StoredProcedure object.

SubSonic.StoredProcedure sp = SPs.CustOrderHist(customerID);

The stored procedure can then either call Execute, ExecuteScalar, GetDataSet or GetReader to execute and return the data.

GridView1.DataSource = sp.GetReader();

Or combining the two statements into one:

GridView1.DataSource = SPs.CustOrderHist(customerID).GetReader();

You can also work with the QueryCommand by referencing the Command property.

Find the entire series of posts here.

Posted on Friday, December 8, 2006 2:03 PM SubSonic | Back to top


Comments on this post: Getting Started with SubSonic - Part 20, Stored Procedures

# re: Getting Started with SubSonic - Part 20, Stored Procedures
Requesting Gravatar...
Hi there, thanks for this although can you provide an example of the following

SubSonic.Schema.StoredProcedure sp = new SubSonic.Schema.StoredProcedure(..., DataService.GetInstance("MySqlDataProvider"))

reason being is that I have existing code that passes in a second parameter that's causing a problem,
Thanks,
Left by James Radford, Web Developer on Mar 16, 2010 3:41 AM

Your comment:
 (will show your gravatar)


Copyright © Scott Kuhl | Powered by: GeeksWithBlogs.net