Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (30 sloc) 1022 Bytes
using CoreDdd.Domain;
using CoreUtils.Extensions;
using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.AcceptanceCriteria;
using FluentNHibernate.Conventions.Inspections;
using FluentNHibernate.Conventions.Instances;
namespace CoreDdd.Nhibernate.Conventions
{
internal class PrimaryKeyConvention : IIdConvention, IIdConventionAcceptance
{
private static string _maxLo;
public static void Initialize(string maxLo)
{
_maxLo = maxLo;
}
public void Accept(IAcceptanceCriteria<IIdentityInspector> criteria)
{
criteria.Expect(x => x.EntityType.IsSubclassOfRawGeneric(typeof (Entity<>)));
}
public void Apply(IIdentityInstance instance)
{
if (instance.Type == typeof(int)
|| instance.Type == typeof(long))
{
instance.Column("Id");
instance.GeneratedBy.HiLo(_maxLo);
}
}
}
}
You can’t perform that action at this time.