I'm trying to learn NHibernate 3.2 built-in mapping by code api
(NOT Fluent NHibernate). Can you help me to map a one-to-one(or zero) relationship between these entities please?
NOTE: I googled the question, also I search the SOF, all examples are using Fluent API or XML; I'm trying to use built-in mapping API in NHibernate 3.2
public class Person {
public virtual int Id { get; set; }
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
// can be null
public virtual Address Address { get; set; }
}
public class Address {
public virtual int Id { get; set; }
public virtual string Line1 { get; set; }
public virtual string Line2 { get; set; }
public virtual string City { get; set; }
// can not be null
public virtual Person Person { get; set; }
}
Primary key strategy is here:
Id(
t => t.Id,
t => {
t.Generator(Generators.HighLow, g => g.Params(new { max_low = 100 }));
t.Column(typeof(TEntity).Name + "Id");
});