I\'m having a problem with NHibernate querying the database way too many times. I just realized it likely relates to the n+1 problem but I can\'t figure out how to change my map
The way to go is to use batch fetching. Read more about it here:
On every entity mapping apply BatchSize
(for many-to-one
relation - avoiding 1 + N)
public ReportMap()
{
Table(...)
BatchSize(25);
...
And on every collection (solves issue with one-to-many
1 + N)
HasMany(x => x.Reports)
.KeyColumn("StackTraceId")
.BatchSize(25)
...