MyGeneration and Gentle.NET

After last week’s post about the stored procs vs. ad-hoc SQL debate, I decided I’d take a look at MyGeneration and Gentle.NET if I could think of the right project. I decided to start with a simple contact form.

Anytime a form has dropdowns, I try to use database tables to populate them.  So I started by copying data for the dropdowns from an existing database to a new one for the project. Once I created a business logic assembly for the new classes to belong to, I fired up MyGeneration and ran the Gentle.NET business entity template. Creating the classes was very easy. the real challenge turned out to be referring to the right Gentle assemblies in my projects. Because I’d included references to Gentle.Common, Gentle.Framework, Gentle.Provider.SQLServer and log4net in the business logic assembly, I thought that was all I needed to do. But the web project wouldn’t compile. In order to get the page working, I had to add Gentle.Common and Gentle.Framework references to web project.

Once I sorted out my reference issues (and added a Gentle.config file), finishing the contact form went very quickly. I developed this bit of code for loading any dropdown list:

private void LoadDropDown(ref DropDownList ddl, IList dropDownItems, string textField, string valueField)
{
ddl.DataSource = dropDownItems;
ddl.DataTextField = textField;
ddl.DataValueField = valueField;
ddl.DataBind();
}

Here’s how it’s called:

if (!Page.IsPostBack)
{
this.LoadDropDown(ref ContactTypeList,BLL.ContactType.ListAll(),”Name”,”ContactTypeId”);
this.LoadDropDown(ref SubjectList,BLL.InformationType.ListAll(),”Name”,”InformationTypeId”);
this.LoadDropDown(ref OrgTypeList,BLL.Audience.ListAll(),”Name”,”AudienceId”);
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.