Skip to content

Instantly share code, notes, and snippets.

@hvitorino
Created October 24, 2011 13:53
Show Gist options
  • Save hvitorino/1309076 to your computer and use it in GitHub Desktop.
Save hvitorino/1309076 to your computer and use it in GitHub Desktop.
Convenções de mapeamento para FluentNH
using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.Helpers;
namespace Aramis.Persistencia.Configuracao
{
public class AramisConventions
{
public static AramisConventions Recupera
{
get { return new AramisConventions(); }
}
private IConvention IdComoPrimaryKey
{
get { return PrimaryKey.Name.Is(pk => "Id"); }
}
private IConvention IdSequencial
{
get { return ConventionBuilder.Id.Always(id => id.GeneratedBy.Identity()); }
}
private IConvention RelacionamentosLazy
{
get { return DefaultLazy.Always(); }
}
private IConvention OperacoesEmCascataParaColecoes
{
get { return ConventionBuilder.HasMany.Always(many => many.Cascade.All()); }
}
private IConvention NomesDosCamposNasTabelasIguaisAsPropriedades
{
get { return ConventionBuilder.Property.Always(prop => prop.Column(prop.Property.Name)); }
}
private IConvention SemConversoesParaEnumeracoes
{
get { return new EnumConvention(); }
}
public IConvention[] Todas
{
get
{
return new IConvention[]
{
IdComoPrimaryKey,
IdSequencial,
RelacionamentosLazy,
OperacoesEmCascataParaColecoes,
NomesDosCamposNasTabelasIguaisAsPropriedades,
SemConversoesParaEnumeracoes
};
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment