Reputation: 73
I have the following linq statement:
var query = from p in session.Query<Parent>().FetchMany(x => x.Children)
select p;
I end up with a new Parent object for each Child in Children. So if i had 5 Children, I would get 5 separate, but identical, Parent objects back. Is this the intended behavior? If i use ISession, I get 1 Parent as expected.
Upvotes: 2
Views: 396
Reputation: 52725
This is expected, because Stateless Sessions do not track objects; therefore each row results in a new instance.
Upvotes: 4
Reputation: 17957
Have you tried to do a Distinct
call on the query?
var results = query.Distinct();
Upvotes: 1