I have a database with a ProbateCases table and a property table. The Properties table has a foreign key for the ProbateCases table called ProbateCaseId, so there is a one-to-many relationship between ProbateCases and the properties.
My domain class has a ProbateCase class and a Property class. The ProbateCase class has a set of properties defined as follows:
private IList<Property> _properties = new List<Property>();
public virtual IEnumerable<Property> Properties { get { return _properties; } }
public virtual Property AddProperty()
{
Property property = new Property();
_properties.Add(property);
return property;
}
The relevant part of the Fluent NHibernate display is as follows:
HasMany(x => x.Properties).Where("Deleted = 0").KeyColumn("ProbateCaseId").Cascade.All().Access.CamelCaseField(Prefix.Underscore);
Note that the association is unidirectional - the ProbateCase class has a set of properties, but the Property class does not have a ProbateCase member.
, - NHibernate SQL ProbateCaseId.
, ProbateCase, , INSERT SQL - SQL Exception, NULL :
INSERT INTO AdminOverview.Properties (PropertyName) VALUES ('Name of property')
, NHibernate , - , ?