narsil/Tanshu.Accounts.Repository/Fluent/ClassConvention.cs

25 lines
908 B
C#
Raw Normal View History

using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.Instances;
using FluentNHibernate.Conventions.Inspections;
using FluentNHibernate.Conventions.AcceptanceCriteria;
using System.Diagnostics;
namespace Tanshu.Accounts.SqlDAO
{
public class ClassConvention : IClassConvention, IClassConventionAcceptance
{
public void Apply(IClassInstance instance)
{
string table = Inflector.Pluralize(instance.EntityType.Name);
table = instance.EntityType.Namespace.Substring(instance.EntityType.Namespace.LastIndexOf('.') + 1) + "_" + table;
Trace.TraceInformation(string.Format("Table for {0}: {1}", instance.EntityType.Name, table));
instance.Table(table);
}
public void Accept(IAcceptanceCriteria<IClassInspector> criteria)
{
criteria.Expect(x => !x.EntityType.IsEnum);
}
}
}