Esempio n. 1
0
        /// <summary>
        /// To use multi criteria to eagerly load multiple child collection, if the first detached criteria has child collection to query,
        /// then must use .SetResultTransformer(new DistinctRootEntityResultTransformer() for the first detached criteria
        /// </summary>
        /// <typeparam name="TRoot">The type of the root.</typeparam>
        /// <param name="multiCriteria">The multi criteria.</param>
        /// <param name="rootCriterion">The root criterion.</param>
        /// <param name="associationPropertyExpression">The association property expression.</param>
        /// <param name="orders">The orders.</param>
        /// <param name="returnDistinctRoot">If set to <c>true</c> [return distinct root].</param>
        /// <returns>A <see cref="IMultiCriteria"/></returns>
        public static IMultiCriteria AddDetachedCriteriaForChild <TRoot> (
            this IMultiCriteria multiCriteria,
            ICriterion rootCriterion,
            Expression <Func <TRoot, object> > associationPropertyExpression,
            IEnumerable <Order> orders = null,
            bool returnDistinctRoot    = false)
        {
            var detachedCriteria = DetachedCriteriaUtil.CreateDetachedCriteriaForChild(
                rootCriterion,
                associationPropertyExpression);

            return(multiCriteria.AddDetachedCriteria(detachedCriteria, orders, returnDistinctRoot));
        }