Oct, 06, 2011
This is a quick console app I put together to demonstrate how SubSonic 3.0 can be used for querying a database. It targets Northwind on SqlExpress.
Currently it demonstrates:
- Retrieving a single record using SingleOrDefault.
- Retrieving all records using All.
- Retrieving a Queryable of records based on some criteria using Find.
- Using Linq query syntax to query.
- Filtered paging.
- CRUD operations.
- Extending generated classes.
- Attaching DataAnnotations to generated classes.
If you need the Northwind scripts, they're available from Microsoft here
I learned a lot while doing this, specifically about the somewhat poor support SubSonic offers for relationships. Rather than bitch and moan about it like I've found everyone else is doing however, I'm going to try (I say this now) to do something about it. I've already got some ideas on how it will work in my head, I think the most difficult part for me will be working with the T4 templates. Will post more about that later.
I also promised someone that I would post my template modifications for allowing IncludeTables. When I find them I will do just that.