1

Any ideas why I might be getting "No persister for: System.Collections.Generic.List" exception when executing the query below?

       var subs = new List<Subsection>();

        var subsections = Session.QueryOver<Subsection>()
                            .WhereRestrictionOn(s => s.Id)
                            .IsInG(subsectionIds)
                            .List<Subsection>();

        Location foreignExpertLocation = null;

        var result = Session.QueryOver<InternationalLawyerExpertise>()
            .JoinAlias(i => i.ForeignExpertLocation, () => foreignExpertLocation)
            .JoinAlias(() => foreignExpertLocation.Subsections, () => subs)
            .AndRestrictionOn(() => subs).IsInG(subsections)
            .Where(i => i.ForeignExpertLocation == location && i.Status.Id == _confirmed)
            .Fetch(lawyer => lawyer.PersonOrganisation.Person).Eager
            .Fetch(lawyer => lawyer.PersonOrganisation.Organisation).Eager
            .List<InternationalLawyerExpertise>();
        return result;
Chirdeep Tomar
  • 4,281
  • 8
  • 37
  • 66

1 Answers1

1

The issue most likely would be in the way how you are creating the subsections "subquery". Try to check this answer: https://stackoverflow.com/a/14080092/1679310

NOTE: There is missing your mapping and definiton of classes, so take this as a "how to" based on your snippet. You should create the detached query:

var subQuery = QueryOver.Of<<Subsection>()
  .WhereRestrictionOn(s => s.Id)
    .IsInG(subsectionIds)
  .Select((s) => s.ID); // ID projection

and then use it:

var result = Session.QueryOver<InternationalLawyerExpertise>()
   ...
   .Where(Subqueries.PropertyIn("SubsectionID", subQuery.DetachedCriteria))

So you can directly in one select filter with inner select (NHibernate will then inject subselect into your main query).

... or provide more details about your mapping..

Community
  • 1
  • 1
Radim Köhler
  • 122,561
  • 47
  • 239
  • 335