A few weeks ago, I blogged about building an alternative to Dynamic Data.  I have to say, it’s pretty sweet.  I added a new entity type yesterday, including a couple of minor overrides and I was done.

Here are the steps I had to take (testing left out for clarity):

  • Create the entity:
  •    1: public class ExcludedCounterparty : IAuditedWithId
       2: {
       3:     public virtual int Id { get; set; }
       4:     public virtual Counterparty Counterparty {get; set;}
       5:     public virtual string CreatedByUser { get; set; }
       6:     public virtual DateTime? CreatedOnDate { get; set; }
       7:     public virtual string ModifiedByUser { get; set; }
       8:     public virtual DateTime? ModifiedOnDate { get; set; }
       9: }
  • Override the Fluent NHibernate conventions:
  •    1: public void Override( AutoMap<ExcludedCounterparty> mapping )
       2: {
       3:     mapping.References( ec => ec.Counterparty, "FK_CounterpartyId" );
       4: }
  • Override the UI conventions:
  •    1: public override void Override()
       2: {
       3:     Config.AllowEdit = false;
       4:     Config.AllowDelete = true;
       5:     Field( ec => ec.ModifiedByUser ).ShouldDisplay = false;
       6:     Field( ec => ec.ModifiedOnDate ).ShouldDisplay = false;
       7: }
  • Add the menu configuration
  •    1: <siteMapNode url="~/../ManageEntities.aspx?type=ExcludedCounterparty" title="Counterparty Exclusions" roles="…"></siteMapNode>
  • Update security
  • Done.

Notice that nowhere did I say that I had to create a aspx page or ascx control.  How sweet is that!  Also, both Fluent and my UI automation automatically pick up the new entity based on the assembly configuration.  It’s days like this that makes software development fun.

posted on Tuesday, June 30, 2009 12:48 PM

Comments

No comments posted yet.

Post A Comment
Title:
Name:
Email:
Comment:
Verification: