views:

9

answers:

1

I'm trying to follow this page http://jagregory.com/writings/fluent-nhibernate-conventions-rewrite/ to define conventions for Fluent NHibernate.

I'm using 1.1.0.685, and when I use this code:

public class TableNameConvention : IClassConvention
{
  public bool Accept(IClassMap classMap)
  {
    return true; // apply to all mappings
  }

  public void Apply(IClassMap classMap)
  {
    // will produce table names like: tbl_Customer, tbl_Product
    classMap.WithTable("tbl_" + classMap.EntityType.Name);
  }
}

..the compiler doesn't know what IClassMap is. IClassConvention yes, IClassMap no. I'm not getting any namespace suggestions from Visual Studio.

My copy of FNH is pretty up to date and the post is from March 11th. Is my version out of date, or is there something else going on?

A: 

What you are after is IClassInstance.

 public void Apply(IClassInstance classMap)
  {
    // will produce table names like: tbl_Customer, tbl_Product
    classMap.Table("tbl_" + classMap.EntityType.Name);
  }
mhenrixon
Magical. Thanks!
David