Subsonic Dreams: Stored Procedures a first class citizen
Posted
Tue, Jul 28 2009 9:03 PM
by
Mischa Kroon
About SubSonic
Let me start off by saying that SubSonic is great, it's my DAL of choice for most projects.
It's small it's fast to set up and it has a whole lot of functionality and elegance out of the box.
You can tell I was pretty exited about it by reading my previous entry about SubSonic.
That said there are a couple of things that in my humble opinion can still be improved upon in the project.
Stored Procedures VS Other Data Access in SubSonic
Data can be inserted / Updated in the following fashion in SubSonic.
Insert a new order for instance could be done like this:
Dim order As New Generated.Orders
order.Name = "My Name"
order.ProductID = 1
order.Isactive = True
order.Save()
dim newOrderID as integer = order.Id
Now if there are columns which are not set through the object all will still work out and the object will still be created.
Stored Procedures are called like this:
sps.CreateOrder("My Name", 1, Nothing, True).Execute()
It would offcourse be great if the Stored Procedures would have the same approach as the SubSonic Object but with some extra's:
Dim order As New sps.CreateOrder
order.Name = "My Name"
order.Ordernr = 1
order.Isactive = True
order.Execute()
With some other parts ready to be used:
dim ReturnValue as integer = order.ReturnValue
dim Output1 as integer = order.NamedOutputParameter
dim Output2 as string = order.NamedOutputParameter2
This way the existing functionality surrounding Stored Procedures would have:
A sexy way of dealing with optional parameters.
A good way to set up parameters out of order with the Stored Procedures.
Some very nice ways of communicating with the output parameters / return value.
Alas I seem to be a little late with this blog post since Subsonic 3.0 has already been released.
And released and released and err, updated.
Offcourse I still hope this can be added to a new version of Subsonic.
So that it can get even better.