From: Richard B. (JIRA) <nh...@gm...> - 2011-04-27 14:13:10
|
[ http://216.121.112.228/browse/NH-2624?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20978#action_20978 ] Richard Brown commented on NH-2624: ----------------------------------- Hi, There is an overload on the IMultiCriteria that takes an IQueryOver, so I would expect the following to work: Session.CreateMultiCriteria() .Add(queryOver) .Add(queryOver.ToRowCountQuery()) .List(); Alternatively, all that does behind the scenes is grab the 'root' criteria, so the following should also work: Session.CreateMultiCriteria() .Add(queryOver.RootCriteria) // not UnderlyingCriteria .Add(queryOver.ToRowCountQuery().RootCriteria) .List(); Can you let me know if that helps? Cheers, Richard > MultiCriteria does not work with criteria created using JoinQueryOver > --------------------------------------------------------------------- > > Key: NH-2624 > URL: http://216.121.112.228/browse/NH-2624 > Project: NHibernate > Issue Type: Bug > Components: Core > Affects Versions: 3.1.0 > Reporter: xelibrion > Assignee: Richard Brown > Priority: Minor > > I've got exception > System.InvalidCastException: Unable to cast object of type 'Subcriteria' to type 'NHibernate.Impl.CriteriaImpl'. > at NHibernate.Impl.MultiCriteriaImpl.CreateCriteriaLoaders() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\MultiCriteriaImpl.cs:line 287 > at NHibernate.Impl.MultiCriteriaImpl.List() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\MultiCriteriaImpl.cs:line 73 > in code > var queryOver = Session.QueryOver<Post>() > .Fetch(x => x.Author).Eager > .Fetch(x => x.Blog).Eager > .JoinQueryOver(x => x.SearchRequests) > .Where(x => x.Id == context.SearchRequestId) > .TransformUsing(Transformers.DistinctRootEntity) > .Skip(context.PageIndex*pageSize) > .Take(pageSize); > Session.CreateMultiCriteria() > .Add(queryOver.UnderlyingCriteria) > .Add(queryOver.ToRowCountQuery().UnderlyingCriteria) > .List(); > I've found workaround using JoinAlias -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |