What is the proper way to bulk insert entities which contain collections of other entities (a HasMany
mapping), using stateless sessions?
E.g. Parent class is mapped like this:
class ParentMap : ClassMap<Parent>
{
public ParentMap()
{
Id(x => x.Id)
.GeneratedBy.Increment();
HasMany(x => x.ChildNodes)
.KeyColumns.Add("Parent_id")
.Cascade.All();
}
}
Stateless session ignores the Cascade option, so child nodes are not persisted automatically. I could iterate through the collection myself, but then I cannot set the relation, because Parent_id
column does not exist as a property I could write to.
Am I missing something?
You have to either create the Parent
property in the child class, or use a stateful session.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With