As I said in the title I need to access and select first object from
entity collection, I do not want to access like Photos.First(). So
even I am not expirienced with projection (someone told thats the only
way) I have something like this
var subQ = QueryOver.Of<Domain.Property>()
.Where(x => x.Id == p.Id)
.SelectList(x => x.SelectMin(y =>
y.Photos.First())); // sub query selecting min photo id from entity
List<Photo> data = session.QueryOver<Photo>()
.Fetch(x =>
x.Property).Eager // eager load the entity
.WithSubquery.WhereProperty(x
=> x.Id).In(subQ)// restrict the photo to those that are the first
ones for the entity
.List().ToList();
Now, with these query I'm selecting Photo with same Id like Property
Id which should not be the case.
When looking in profiler I'm selecting 18 Photo entities and 18
Property which is ok. But identifiers are the same.
If I change line .WithSubquery.WhereProperty(x => x.Property).In(subQ)
I then load all 59 entities which is performanse disaster.
Please point me in the right direction
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.