Beginnermediate ASP.NET

ASP.NET for newbs to intermediate

Coolness of SubSonic

From my last post SQL Parameters in C# I mentioned that I wanted to learn an ORM package.  Well I took a quick glance at NHibernate and got overwhelmed and decided to take a look at SubSonic as I have heard a lot of good things about it.  Well I am happy to say I doubt I will EVER do database access by hand ever again if I can help it.  As such I figured I would make a code post on some SubSonic code.  I am not really going to explain it just want to show you how easy, cool and simple it is.  I'll show the code starting with my .aspx main aspx page code, the code behind then the data access layer code.

.aspx Code

Code Behind

DataAccess Class

Product Class

I am also including the project I used too.  Be sure you have Northwind database.

I suggest you download, install, and start using SubSonic.  It is a great framework to help generate and create your DAL.  Once you have it I suggest you watch the screencast on the using the Query Tool.  If you would like me to explain this code i'd be more than happy to just let me know and I'll make another post.

SubSonicTest.zip (188.54 kb)

Posted: Jan 23 2008, 10:20 PM by percent20 | with 4 comment(s) |
Filed under: , , ,

Comments

Kenneth said:

Remember to close the reader :-)

# January 24, 2008 3:37 AM

rrobbins said:

Would SubSonic or any kind of ORM package be useful in a situation where a web site was occassionally being moved from host to host with different database support, MySQL or SQL Server? I have clients on a budget that are always trying to save money by changing hosting companies but I would argue that it costs more to keep changing the web application for different database systems.

# January 24, 2008 8:51 AM

percent20 said:

@Kenneth oopsy thank you for that.

@rrobbins that is the neet thing about SubSonic is it suppports several Databases out of the box. Currently it supports SQL 2000, SQL 2005, MySQL, and Oracle.  They are going to add support for SQLLite, SQLCE and PostGre too.  You will just need to change the configuration in the web.config file.

# January 24, 2008 9:18 AM

Beginnermediate ASP.NET said:

Yesterday in the " Coolness of SubSonic " post I had a bit of asp.net markup (as I call it) that would

# January 24, 2008 8:15 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)