Archives

Tagged ‘T4‘

Setting up SubSonic3 Repository Mode with an Existing Database

Using SubSonic 3 respository mode has been a breath of fresh air for some of my projects. You can use simple POCOs (plain old CLR objects) and easily use inversion of control with your application. However, it can be a little confusing using repository mode with an existing database since SubSonic’s default schema naming may not conform to your database. By using SubSonic’s schema attributes, you can get your application up and running relatively easily; and if you have a ton of tables, I have a T4 template that generates basic domain classes against your database to get you started.

Read more →

SubSonic3 Works on Mono!

SubSonic  ProjectSo a couple weeks ago I decided to test a few changes made to SubSonic3 that fixed a LINQ evaluation bug related to medium trust. Using a simple console app on linux/mono, I tested basic data access to a SQLite database using repository mode, and to my surprise it worked!

Mono-gorilla-aqua.100px

I’ve always been a big fan of SubSonic since its 2.0 version, which I used for a mid-sized e-commerce site. With a totally rewritten core, 3.0 uses LINQ (language integrated query) for all of its data access providing a great alternative to Dblinq for the Mono platform.

 

 

Read more →

Simple Linq to Sql Enhancements with T4 Templating

I sometimes underestimate the power of the tools that come with visual studio. Usually this is because I’m ignorant of the fact they even exist until I see them used or read about them somewhere else. T4 text generation is no exception.  This is a very useful tool that’s built right into Visual Studio 2008 which I discovered while peeking at the new SubSonic 3 code when it came out. (Thanks Conery). :)

After spending a day drilling into T4 and learning how it works, I have to say that it was definitely time not wasted. I’ve since used it for tons of miscellaneous code generation projects including mostly data layer extensions. And with the help of the data provider specific templates in the SubSonic project, much of the schema extraction code has been provided for us through open source.

I’m a big fan of SubSonic, and I like to push it in all the shops I work with that aren’t already anchored down to another data framework. However, sometimes we still have to fall back to vanilla data layers like Linq to Sql (L2S), Entity Framework (EF), or straight up ADO.Net depending on the shop and its personalities. Having experience using SubSonic opens your eyes to some useful ways you can improve L2S and the others.

Read more →