// gets the GROUP BY / ORDER BY sql // required in order to count children protected Sql <ISqlContext> AddGroupBy(bool isContent, bool isMedia, bool isMember, Sql <ISqlContext> sql, bool defaultSort) { sql .GroupBy <NodeDto>(x => x.NodeId, x => x.Trashed, x => x.ParentId, x => x.UserId, x => x.Level, x => x.Path) .AndBy <NodeDto>(x => x.SortOrder, x => x.UniqueId, x => x.Text, x => x.NodeObjectType, x => x.CreateDate); if (isContent) { sql .AndBy <DocumentDto>(x => x.Published, x => x.Edited); } if (isMedia) { sql .AndBy <MediaVersionDto>(x => Alias(x.Path, "MediaPath")); } if (isContent || isMedia || isMember) { sql .AndBy <ContentVersionDto>(x => x.Id, x => x.VersionDate) .AndBy <ContentTypeDto>(x => x.Alias, x => x.Icon, x => x.Thumbnail, x => x.IsContainer, x => x.Variations); } if (defaultSort) { sql.OrderBy <NodeDto>(x => x.SortOrder); } return(sql); }