Created
October 24, 2011 13:53
-
-
Save hvitorino/1309076 to your computer and use it in GitHub Desktop.
Convenções de mapeamento para FluentNH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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