public IList <ProcedureTypeGroup> Find(ProcedureTypeGroupSearchCriteria criteria, Type subClass, SearchResultPage page)
        {
            HqlQuery query = new HqlQuery(string.Format("from {0} x", subClass.Name));

            query.Conditions.AddRange(HqlCondition.FromSearchCriteria("x", criteria));
            query.Sorts.AddRange(HqlSort.FromSearchCriteria("x", criteria));
            query.Page = page;

            return(ExecuteHql <ProcedureTypeGroup>(query));
        }
        /// <summary>
        /// Adds the specified ordering to the specified query, pre-pending the specified qualifier.
        /// </summary>
        /// <param name="qualifier"></param>
        /// <param name="query"></param>
        /// <param name="criteria"></param>
        /// <param name="remapHqlExprFunction"></param>
        /// <remarks>
        /// All HQL dot expressions are passed through the <paramref name="remapHqlExprFunction"/>, allowing the expression
        /// to be modified prior to be added to the query.
        /// </remarks>
        public static void AddOrderingToQuery(string qualifier, HqlProjectionQuery query, WorklistItemSearchCriteria[] criteria,
                                              Converter <string, string> remapHqlExprFunction)
        {
            // use the sorting information from the first WorklistItemSearchCriteria object only
            // (the assumption is that they are all identical)
            var c = CollectionUtils.FirstElement(criteria);

            if (c == null)
            {
                return;
            }

            var sorts = HqlSort.FromSearchCriteria(qualifier, c, remapHqlExprFunction);

            query.Sorts.AddRange(sorts);
        }
Esempio n. 3
0
        public IList <TEntity> Find(TSearchCriteria[] criteria, SearchResultPage page, EntityFindOptions options)
        {
            var query = new HqlProjectionQuery(new HqlFrom(typeof(TEntity).Name, "x"))
            {
                Page = page, Cacheable = options.Cache
            };

            // add fetch joins
            foreach (var fetchJoin in GetDefaultFetchJoins())
            {
                query.Froms[0].Joins.Add(new HqlJoin("x." + fetchJoin, null, HqlJoinMode.Inner, true));
            }

            // apply lock hint
            if (options.LockForUpdate)
            {
                query.SetLockMode("x", LockMode.Upgrade);
            }

            var or = new HqlOr();

            foreach (var c in criteria)
            {
                var and = new HqlAnd(HqlCondition.FromSearchCriteria("x", c));
                if (and.Conditions.Count > 0)
                {
                    or.Conditions.Add(and);
                }

                query.Sorts.AddRange(HqlSort.FromSearchCriteria("x", c));
            }

            if (or.Conditions.Count > 0)
            {
                query.Conditions.Add(or);
            }


            return(ExecuteHql <TEntity>(query, options.Defer));
        }