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

25 lines
902 B
C#
Raw Normal View History

using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.Inspections;
using FluentNHibernate.Conventions.Instances;
using FluentNHibernate.Conventions.AcceptanceCriteria;
using System.Diagnostics;
namespace Tanshu.Accounts.Conventions
{
public class PrimaryKeyConvention : IIdConvention, IIdConventionAcceptance
{
public void Apply(IIdentityInstance instance)
{
Trace.TraceInformation("PK on {0}.{1}", instance.EntityType.Name, instance.EntityType.Name + "ID");
instance.Column(instance.EntityType.Name + "ID");
//instance.GeneratedBy.Assigned();
//instance.Access.ReadOnlyPropertyThroughCamelCaseField(CamelCasePrefix.None);
}
public void Accept(IAcceptanceCriteria<IIdentityInspector> criteria)
{
criteria.Expect(x => x.Name == x.EntityType.Name + "ID");
}
}
}