C# Code Generator for the DAL
Hi all.
I need a recommendation. I am looking for a C# Code Generator for the DAL. No matter if I have to pay, thing here is saving time.
The features that the product should meet are:
1-N–layers enabled.
2-SQL2005 supported.
3-If possible integrating Enterprise Library (application blocks).
4-For the DAL (data access layer) we need that :
a.Generates Typed Data Sets.
b.Using store procedures is alternative.
5-Easy retrieve of changes from the database schema.
6-Easy to maintain.
I have been testing some tools as Code Author and Dalgen. But all of them have the same problems.
a- it is using sprocs (I would like not to use sprocs but hard coded sentences).
b- The BLL has to be recreated when a new field is added to the database, so if you have written your custom changes into these objects you will loose it.
Any suggestion?
Hi
do you really need typed datasets, or could you go all objects, all the way?
if so nHibernate is an option
otherwise check out:
- codesmith
- llbgen
- ...
hope this helps you out
I have tried codesmith and llbgen. I will check it out for nhibernate.
Thanks.
just a quick note 
I use nhibernate for persisting objects. it allows for a "no code solution", just use the mapping.attributes on your class members.
nHibernate also allows to do partial selects (check out the examples on the hibernate query language) to create reports and so on. I personally consider this kind of dirty, so I don't use that...
You can access the underlying db connection from the Session.Connection property and pass a call to a stored procedure using standard ado.net (or build some wrapper functionality)
Hope this helps you out!
Hi,
Based on my research for quite a long time, i have found that if you can go without storproc or can afford writing custom classes for calling stor proc, CODUS(www.adapdev.com) is the best DAL generation tool (it don't creates typed dataset though it creates datasets).It saves the custom made changes also
Its best point is that all of its source code is available.
Otherwise , you can go for TierDeveloper, it have support for stored procedures(i am not sure about typed dataset),but i can say that it is a very rich tool in terms of functionality, just check source code availability and licensing terms of applications developed on it.
Don't go for nhibernate as it generates query at the runtime using an engine and it is little left to you to optimise it.There are many scenarios when people put some patches to tweak the queries of nhibernate but then design of application becomes dirty and unmaintainable.It hits the performance as it maintains catch of queries fired recently and replication of this cache on a clustered environment will again be a added design effort and performance loss.
Cheers
"
Don't go for nhibernate as it generates query at the runtime using an engine and it is little left to you to optimise it.There are many scenarios when people put some patches to tweak the queries of nhibernate but then design of application becomes dirty and unmaintainable.It hits the performance as it maintains catch of queries fired recently and replication of this cache on a clustered environment will again be a added design effort and performance loss."
I'm sorry but I just can't agree with your statements here. There is four things that are incorrect:
1) Auto-generating queries is for the majority of all queries not a performance issue, sometimes ORMs like NHibernate even generate more efficent queries since they can consider all the facts before creating it. There is a well thought through query language for doing object queries (in NH's case it's called HQL) which allows for shaping queries like you want them, based on the conceptual datamodel you have created.
2) Most ORM, and even so NH, has the capability to execute any SQL statement you choose and return the result as objects, just like any other persistance layer would / can.
3) Maintanance of an application based on an ORM like NH is often much easier then when you create numerous of queries on your own. Since they autogenerate much of their queries, I don't have to worry about changes in the data model. Since ORMs has mapping information, you change that mapping and all auto-generated queries will be automatically updated as well. No need to find all queries and add/remov columns och change joins by hand.
4) When you say cluster I'm assuming you mean load balancing, clusters is for fail over, and no, the cache that NH carries can be a distributed one. There is numerous of distributed caching alternatives that has support for NH, to name two there is memcached (https://sourceforge.net/projects/memcacheddotnet/) and NCache (http://www.alachisoft.com/index.html )
When it comes to over all performance issues not related to queries, yes ORM will be slightly slower in filling your objects then if you did it manually, but when it comes to performance tweaking, changing the way data moves from data readers to objects is probably one of the last places one actually need to look at.
The trade off though is that you will be able to much quicker and with less effort, create and maintain persitance layers in your application.
NH (and Hibernate which it is based on, a java ORM that has been around for ages) and other ORM has broad user base and are used in alot of applications. Theese users have during the years of development provided a hugh amont of feedback to the ORM developers and they are today very mature and fine tuned for building scalable enterprise applications.
To answer the original question:
If NH won't be your posion,
LLBLGEN has a lot of momentum in the .NET world. Frans Bouma who is head architect of the framework has been working with DAL generation for a long time and is very skilled in that field.
Another really great DAL generator is SubSonic which also carries a lot of respect in the community ( http://www.codeplex.com/actionpack ).
NHibernate is my preference for the DAL as well.
If you need something with less of a learning curve (for simpler applications) take a look at SubSonic.
Actually I am getting familiar with subsonic.
It is little poor in documentation.
does anyone have a user guide or something similar?
Product looks great , but the documentation.
what's your experience with subsonic? is it buggy?
thanks.
Hi Lowendahl,
With due respect to your remarks, what i said was based on a long proprietary evaluation with performance analysis done by us.We had also taken distributed cache in this exercise.It do helps us in clustering but as each node has to check the cache object map in every node and cache needs to be replicated for this at every node, it altogether degardes the performance.
You might like to visit to http://nikhilb020875.wordpress.com/tag/orm/ for reading more about what i wanted to say.
BTW, thanks to thread thread for letting me know about a new DAL genration tool,subsonic.
Cheers
I started to write a post about your comments, since the problems you are talking about has nothing to do with ORM but rather with poor architecture or design in Load Balancing scenarios. But my good friend Mats Helander (Author of the VB6 mapper PragmaTier and .NET mapper NPersist) beat me to it.
Have a read over here: http://www.matshelander.com/wordpress/?p=59
Your best bet here us .NetTiers, of all the generators metioned here is why I think so:
1. It is more peroformant that NHibernate, we tried it on enterprise level applications with thousands-millions of users.
2. It is based on MS enterprise library.
3. It is easier to learn then LLBLGEN, but not as easy as NHibernate (should be easy enough though)
4. Has a great persistence pattern (Data providers, ECC pattern).
5. Has a large open source communit behind it.
6. Uses Codesmith templates to generate, so you can easily modify and change behaviour, as well as learn to generate your own code.
Tell me if what you think:
http://www.nettiers.com/