SubSonic - Code Camp slides posted
Slides and sample code from my talk on SubSonic from the SoCal Code Camp a week ago are available here. The slides were pretty light since my talk was geared towards building some very simple sample pages on the fly.
The one shortcut I took was to copy web.config and DLL's from the SubSonic Central site included with the SubSonic download - I think that was a good approach, since I didn't have to bore everyone with manually typing configuration files, but I didn't have to use the demo hammerspace technique of copying a bunch of code out of some text document I'd set up beforehand. Sure, it's a cheat, but it's a cheat you can use when you get home from the talk, too.
Here's the text from the slides:
SubSonic
Using SubSonic to build ASP.NET Applications that are good, fast, and cheap
Jon Galloway
SoCal Code Camp July 2007
Overview
* What is SubSonic
* Simple – WebSite project with build provider
* More advanced – Using SubCommander to generate code
* Simple again – Using a the SubSonic Starter Site
What is SubSonic
* Lightweight data access layer (DAL) built on ActiveRecord pattern
– SQL Server 2000
– SQL Server 2005
– MySQL
– Oracle
– EntLib
* Controls built on top of SubSonic DAL
* “Sugar” – Utilities
Overview
* History
* SubSonic 1.0 – Zero Code DAL, scaffold
* SubSonic 1.0+ – SubCommander, more controls
* Subsonic 2.0 (current is 2.0.2) – Starter site with CMS and Membership, AutoScaffold, more controls
Our Pal, Northwind
(screenshot of Northwind tables I’ll be working with)
Build Provider DAL
* Overview of the concept
* Demo
(Remember to cheat by copying config and DLL’s in from SubSonic Central)
(Remember to copy connectionstring.config)
SubCommander
* Overview
* Demo
– Command Line, Toolbar
– Look at generated code
(Yes, there’s dynamic SQL in there. Here’s why it’s okay…)
– Modify database
(again, remember to copy connectionstring.config)
Sample Database
(screenshot of sample database for demo)
Starter Site
* First show in SubSonic solution
* Look at CMS
* Build some pages
– Query
– Controls
– LoadFromPost (time permitting)
Starter Site Demo Cheat Sheet
* Add connection string
<add name="CodeCamp" connectionString="Data Source=.\SQL2005;Integrated Security=True;Database=CodeCampSite"/>
* Add provider line
<add name="CodeCamp" type="SubSonic.SqlDataProvider, SubSonic"
connectionStringName="CodeCamp"
generatedNamespace="CodeCamp"
generateLazyLoad="true"
generateRelatedTablesAsProperties="true"
/>
Starter Site Cheat Sheet
* Set up AutoScaffold page
* Clear content from CMS
protected void ClearCMS_Click(object sender, EventArgs e) { CMS.PageCollection pc = new CMS.PageCollection(); pc.Load(); foreach (CMS.Page p in pc) CMS.Page.Destroy(p.PageID); }