doubts when mapping nhibernate

Asked

Viewed 355 times

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 the mapping of this class using: NHibernate.Mapping.ByCode.Conformist or Fluentnhibernate

  • 1

    http://answall.com/questions/22354/como-usar-o-fluent-nhibernate-apropriadamente?rq=1

1 answer

4


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 here, here and here, will definitely clear your head. And, if you’re starting now, take a look at Activerecord.

  • Remember that you need to map the table, so before Id, put Table("Owner.Tablename");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.