I having some trouble with a Linq NHibernate query.
I need to get a batch of vouchers with their details. As I need to iterate them, I wanted to get all the information in a single execution.
My query is the following one:
return this.Session.Query<VouchersToIntegrate>()
.Take(query.BatchSize)
.Fetch(x => x.VoucherLines)
.ToList();
Where VouchersToIntegrate is the voucher and VoucherLines the lines of each voucher.
The batchSize is set to 50.000 now, but when I return all the objects, I just get 23XXX. This is because I guess the framework is internally executing a distinct after it gets all the objects from the database (client-side). Is there any other way to get the 50.000 objects with the distinct filter in the SQL server side?
Thanks