How can i ignore map property in NHibernate with setter
Posted
by
Emilio Montes
on Stack Overflow
See other posts from Stack Overflow
or by Emilio Montes
Published on 2012-03-23T17:07:44Z
Indexed on
2012/03/23
17:29 UTC
Read the original article
Hit count: 370
i need ignore map property with setter in NHibernate, because the relationship between entities is required. this is my simple model
public class Person
{
public virtual Guid PersonId { get; set; }
public virtual string FirstName { get; set; }
public virtual string SecondName { get; set; }
//this is the property that do not want to map
public Credential Credential { get; set; }
}
public class Credential
{
public string CodeAccess { get; set; }
public bool EsPremium { get; set; }
}
public sealed class PersonMap : ClassMapping<Person>
{
public PersonMap()
{
Table("Person");
Cache(x => x.Usage(CacheUsage.ReadWrite));
Id(x => x.Id, m =>
{
m.Generator(Generators.GuidComb);
m.Column("PersonId");
});
Property(x => x.FirstName, map =>
{
map.NotNullable(true);
map.Length(255);
});
Property(x => x.SecondName, map =>
{
map.NotNullable(true);
map.Length(255);
});
}
}
I know that if I leave the property Credential {get;} I was not going to take the map of NHibernate, but I need to set the value.
Thanks in advance.
© Stack Overflow or respective owner