2011-03-11 18:49:48 +00:00
|
|
|
|
using FluentNHibernate.Conventions;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
using FluentNHibernate.Conventions.Instances;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
using FluentNHibernate.Conventions.Inspections;
|
|
|
|
|
using FluentNHibernate.Conventions.AcceptanceCriteria;
|
|
|
|
|
using System.Diagnostics;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.SqlDAO
|
|
|
|
|
{
|
2011-02-18 16:54:48 +00:00
|
|
|
|
public class ClassConvention : IClassConvention, IClassConventionAcceptance
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
|
|
|
|
public void Apply(IClassInstance instance)
|
|
|
|
|
{
|
|
|
|
|
string table = Inflector.Pluralize(instance.EntityType.Name);
|
|
|
|
|
table = instance.EntityType.Namespace.Substring(instance.EntityType.Namespace.LastIndexOf('.') + 1) + "_" + table;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
Trace.TraceInformation(string.Format("Table for {0}: {1}", instance.EntityType.Name, table));
|
2011-01-30 07:14:05 +00:00
|
|
|
|
instance.Table(table);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Accept(IAcceptanceCriteria<IClassInspector> criteria)
|
|
|
|
|
{
|
|
|
|
|
criteria.Expect(x => !x.EntityType.IsEnum);
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|