Today, I updated the ActiveRecord Code Generator a bit. I checked in changes to use primary and foreign key details from INFORMATION_SCHEMA. The original code used naming conventions to decide what various fields were used for - ID = Primary Key, Field_ID = Foreign Key to table Fields. If you want to use naming conventions, let me know and I can add a setting in App.Config to allow this (along with any "real" key constraints).
My current development environment is Visual Studio Express C# Edition (read that as free ), Castle ActiveRecord's latest svn trunk(usually within a few days), and NHibernate svn trunk. As of NHibernate version 1.2.0, there is a very cool new class out there ... DetachedCriteria. This class lets you set all of your Castle relational attributes like BelongsTo, HasMany, etc. as lazy fetch, and over-ride this for searches, reports, or anytime you know ahead of time that you will be touching the related classes by calling detachedCriteria.SetFetchMode(..., FetchEnum.Eager). As a good netizen, I have tried to contribute to NHibernate and Castle ActiveRecord even if only in the smallest of ways . Oh yeah, I tried mapping to a SQL VIEW, and it worked GREAT! I received a comment after my last post, indicating that there is a better way, and I am sure of it, but the view guaranteed that I only have one database request for my dataset. NHibernate was wanting to re-fetch my missing as
Comments
I am new to both NHibernate and ActiveRecord, so working throught these issues is taking me a while, but, I do intend to research all of them completely. If you would like, I would be glad to assist improving the tool.
BTW, I do really like the idea of removing plurals from the table names. I have not seen that feature in some other code generators for NHibernate.
I need to just read information on plural table / singular class from a file, and only fall back to my guess-work code if no entry is found. That will allow us to build a word list up, checked in to source control, and released with the app.
private ChangeContro _changeContro;
FYI, in my source version I added a "Browse..." button for the output folder.
private void btnBrowse_Click(object sender, EventArgs e)
{
System.Windows.Forms.FolderBrowserDialog dlg = new FolderBrowserDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
this.OutputDir = dlg.SelectedPath;
}
}