SubSonic 2.0 (the zero code data access layer) just hit Beta 1 today. Download it, marvel at all the cool new features, and get your feedback in quickly because they're planning a really short beta phase with a final release as early as next Wednesday.
I got fired up about SubSonic when I first saw it last August and wrote that Microsoft should ship it with ASP.NET AJAX (then called ATLAS). I knew it wouldn't happen, but I still think I was right. SubSonic is a zero code data access layer for ASP.NET - drop the DLL in your bin directory and add a few lines to your web.config, and you get immediate access to classes and controls that make ASP.NET work as if it was built just for you and your database.
Part of what got me excited was that my first feature request was implemented and released less than two hours after I left it in a comment on Rob's weblog. They haven't slowed down a bit.
Here's what's new in the 2.0 release (lifted from Rob's release announcement):
- Multiple Database support! Now you can generate a full DAL for as many databases as you like.
- Enterprise Library 3.0 Support. Just added this in and it works nicely.
- All-new command-line tool. You can now use our command-line tool (called SubCommander) to do all kinds of fun things, like generate your code and version your database. You can even hook into it using Visual Studio's External Tools - this will allow you to generate your project's code with the click of a button, and it will use your project settings (look for a blog post on Rob's blog).
- Improved querying. You can now use our Query tool to run OR's, IN's, and aggregates. You can even type what you want to see:
IDataReader rdr = new SubSonic.Query("Products").WHERE("CategoryID = 5").ExecuteReader();
We've also renamed many of our methods (well, we've added aliases) to make the query more readable. You can now use WHERE, AND, OR, IN, BETWEEN_AND, etc. to make your calls that much more readable.
- New Controls. You can now use our Smart Dropdown, which loads itself:
<subsonic:DropDown id=mySmarty runat=server tablename="categories" />
You can also use our new ManyToMany Checkbox list helper to both list and save information for many to many relationships:
<subsonic: ManyManyList id=myList runat=server MapTableName="Product_Category_Map" PrimaryTableName="Products" PrimaryKeyValue="1" ForeignTableName="Categories" />
- A new AutoScaffold page that you can drop right into your project to admin all your tables. This thing reads your tables and creates scaffolds for you automagically (thanks Eric!).
- A completely reworked code-generation system that uses an ASP-style templating system. You can now code up your templates like you would an ASP page (also just like CodeSmith). Test them in your web site to make sure they work, then replace (or add to) the bits that get generated at runtime. You can override our templates by specifying a template directory in the web.config:
<SubSonicService defaultProvider="Northwind" fixPluralClassNames="false" templateDirectory="D:\PathToMyTemplates">
- Regular Expression Naming Engine. If you don't like what our convention is, then you can use your own with some simple regex. Pass a simple string, or a dictionary replacement and all of your tables/views will be renamed as you specify.
- Query Inspection. Want to know what's happening to your query, and how long it's taking? You can simply use the new Inspect() method which outputs the results and statistics to HTML for you to review.
- Improved Trace/Debug. We've added tracing to (almost) every facet of SubSonic, so if you turn tracing on you can see what SubSonic's trying to do. We're always adding to this and if you see something we've missed, let us know :).
- Improved Scaffolding. Your foreign key values are now pulled into the GridView and displayed instead of their keys. Eric figured this one out - go dude!
My favorites are probably the command-line tool, scaffolding improvements, the auto-scaffold, and the code generation system. Here's why:
- The command-line tool (sonic.exe) lets you work with SubSonic however you'd like. Previous releases of SubSonic required you to either use a build provider (which only works in ASP.NET 2.0 Web Site Projects, not Web Application Projects), or through a web page which would generate your DAL code. sonic.exe removes that restriction and gives you full and complete access to just about anything SubSonic can do. Since SubSonic's data engine is pretty much SQL Server Management Object (SMO) on steroids + support for other databases like MySQL and Oracle, command line access lets you do things with your data that make a lot of sense even if you never touch ASP.NET. sonic.exe can script out your database (schema and / or data) and build you a complete data access layer based on default templates or templates you provide, which is pretty nice for any .NET data application. Phil and I contributed some code to this, and we're using it in a current application for a large client. It works very well.
- Scaffolding improvements are a big deal. The original scaffold control was nice for developer admin interfaces, but there were a few problems that kept me from using it in live applications. One problem was that the scaffold showed ID values for foreign key columns. In the new release, the scaffold follows the columns to show the values from the foreign keyed tables, which is really slick. Even nicer is that you can output the code for a scaffold using sonic.exe, which means you can do whatever you can customize it as much as you'd like.
- The AutoScaffold is a great timesaver. It gives you a complete admin interface to your entire database - view, add, edit and delete for all tables - with zero code. Note that the editor controls are automatically generated - calendar controls for date values, dropdowns for foreign keyed values, etc.
- The changes to the code generation system to use ASP.NET style templates, which will make it easier to fit this in with existing projects or standards. Even better, this will open the door for community development and improvement of templates, and that can't be bad.
It's ironic that I need to wrap this up to get back to writing a tip for the ASP.NET book I'm co-authoring (with Phil Haack, Jeff Atwood, and K. Scott Allen). This tip, scheduled and assigned to me months ago, is on SubSonic. I had a chat with Rob about some upcoming features to include in the book, and I can only say that they're even better than this 2.0 stuff.