public virtual IList <PageCountResult> GetAllPageCount(IEnumerable <long> projectIdList) { PageResource pageResourceAlias = null; Resource resourceAlias = null; Project projectAlias = null; PageCountResult resultAlias = null; var result = GetSession().QueryOver(() => pageResourceAlias) .JoinAlias(x => x.Resource, () => resourceAlias) .JoinAlias(() => resourceAlias.Project, () => projectAlias) .WhereRestrictionOn(() => resourceAlias.Project.Id).IsInG(projectIdList) .And(x => x.Id == resourceAlias.LatestVersion.Id && !resourceAlias.IsRemoved && projectAlias.IsRemoved == false) .SelectList(list => list .SelectGroup(() => resourceAlias.Project.Id).WithAlias(() => resultAlias.ProjectId) .SelectCount(() => pageResourceAlias.Id).WithAlias(() => resultAlias.PageCount)) .TransformUsing(Transformers.AliasToBean <PageCountResult>()) .List <PageCountResult>(); return(result); }
public virtual IList <PageCountResult> GetBooksPageCountByGuid(IList <string> bookGuidList) { using (var session = GetSession()) { Book bookAlias = null; BookPage bookPageAlias = null; PageCountResult resultAlias = null; var result = session.QueryOver <BookVersion>() .JoinAlias(x => x.Book, () => bookAlias) .JoinAlias(x => x.BookPages, () => bookPageAlias, JoinType.LeftOuterJoin) .SelectList(list => list .SelectGroup(() => bookAlias.Id).WithAlias(() => resultAlias.BookId) .SelectCount(() => bookPageAlias.Id).WithAlias(() => resultAlias.Count)) .Where(x => x.Id == bookAlias.LastVersion.Id) .AndRestrictionOn(() => bookAlias.Guid).IsInG(bookGuidList) .TransformUsing(Transformers.AliasToBean <PageCountResult>()) .List <PageCountResult>(); return(result); } }