doubts when doing nhibernate mapping

0

I have the following scenario:

public class ExemploDTO
{
    public virtual int Id { get; set; }
    public virtual List<PessoaDTO> Cliente { get; set; }
    public virtual ServicoDTO Servico { get; set; }
}

How would map this class using: NHibernate.Mapping.ByCode.Conformist or Fluentnhibernate

    
asked by anonymous 18.02.2015 / 19:33

1 answer

3

Using Fluent would look like this:

public class ExemploMap : ClassMap<ExemploDTO>
{
    public ExemploMap()
    {
        Id(x => x.Id);
        .Length(10)
        .Not.Nullable();
        References(x => x.ServicoDTO);
        HasMany(x => x.PessoaDTO);
    }
}

I advise you to take a look at here , here and here , It will certainly lighten your ideas. And if you're starting now, take a look at ActiveRecord.

    
18.02.2015 / 21:02