Tutorial :CodeSmith v.s. T4: .netTiers level suite



Question:

Has someone ported the netTiers template set to Visual Studio's T4 templates? Or is there a system of similar scope? Does anyone use T4 in a work environment? What (if any) major differences are there between Codesmith and T4?


Solution:1

I dabbled in T4 for a bit - hey, if it's free and included in VS2008, use it, right?

My basic idea was to create a set of templates to read a database table, and create our own "roll-your-own" ORM classes from it.

I gave up on T4, frustrated and unable to get even the most basic things to work that are a piece of cake in CodeSmith.

Even a simple task such as selecting what server, database, and table to use cannot be done in T4 efficiently from "outside" the template itself. Yes, you can hard-code all these values as string values into a T4 template - but c'mon, that's really not a solution, is it?

CodeSmith has great support for picking server, database, and tables, and you can set those as properties on the template and just pick what you want and let the template do your stuff on that particular table you picked.

My conclusion: T4 is promising, but "not there" just yet. It might work for very simple scenarios, but right now, it's in my opinion nowhere near as flexible and powerful as Codesmith.

For for a scenario such as .netTiers, I'd stick with Codesmith for the time being.

Marc


Solution:2

T4 is not CodeSmith. Yes, you specify parameters in a .tt file in the form of C# or Visual Basic code and use an <#@ include #> directive to reference the actual implementation of the code generation logic. This is not more hard-coding than specifying the same information in an XML file with CodeSmith.

For a NetTiers-like suite of T4 templates, check out S#arp Architecture: http://code.google.com/p/sharp-architecture/.


Solution:3

If you are looking for a T4 implementation of a well supported DAL that is Open Source with a Linq interface as well as its own Fluent interface that will create wrappers for Tables, Stored Procs, Views etc. Then you need to try SubSonic 3.0. SubSonic 2.2 has the same goodness minus the T4 and the Linq interface and is in release mode. SubSonic 3.0 is in Alpha but you can download the code or a .dll and the T4 templates if you like.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »