CodeSmith v.s. T4: .netTiers level suite
Asked Answered
G

3

6

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?

Galenic answered 13/5, 2009 at 1:5 Comment(2)
I am also interested to know how people overcome the fact that each T4 template generates only one output file.Whelk
olegsych.com/2008/03/…Hylan
S
5

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

Salop answered 13/5, 2009 at 5:54 Comment(3)
You could of course have settings in a separate template and just include it in your main generation template. This way, your settings file will be small and everything will be contained in a single file. Could be called settings.ttUnknot
@Robert: sure - but that doesn't solve the fundamental problem - there's no easy way to pass parameters to T4 templates right now - a MAJOR drawback in my opinionSalop
I know this is an old question, but just in case anyone stumbles across the discussion -- T4's now have a "Parameter" directive. olegsych.com/2010/05/t4-parameter-directiveNee
L
5

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/.

Libra answered 13/5, 2009 at 11:13 Comment(0)
S
1

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.

Smacking answered 13/5, 2009 at 18:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.