Im just trying to work out if its possible to map a 1 - 0..1 (one to at most one \ one to zero or one) relationship using fluent NHibernate without the use of a Private Collection. An example of the class structure is below:
public class ClassA
{
public int ClassAId { get; set; }
public string SomeDetails { get; set; }
public ClassB ClassB { get; set; }
}
public class ClassB
{
public ClassA ClassA { get; set; }
public int ClassBId { get; set; }
public string SomeChildDetails { get; set; }
}
In this example, ClassA can have a ClassB, or ClassB can be null.
The DB structure would look something like:
ClassA Table
-------------
int ClassA_ID PK
string SomeDetails
ClassB Table
------------
int ClassA_Id PK FK
string SomeChildDetails
In this situation, you cannot use HasOne(x => x.ClassB).Cascade.All(); as this assumes it must always have one.
Is there a way to do this without having a one to many relationship with a private IList on ClassA and having the getter of the ClassB property getting the first entry in the list.
Ta
R
int?
? – Oskar Kjellin