/// <summary>
        /// Sets the fetch mode.
        /// </summary>
        /// <typeparam name="T">Type setting fetch mode for.</typeparam>
        /// <typeparam name="TProperty">The type of the property.</typeparam>
        /// <param name="criteria">The criteria.</param>
        /// <param name="associationPropertyExpression">The association property expression.</param>
        /// <param name="mode">The mode to set.</param>
        /// <returns>A <see cref="DetachedCriteria"/></returns>
        public static DetachedCriteria SetFetchMode <T, TProperty> (
            this DetachedCriteria criteria, Expression <Func <T, TProperty> > associationPropertyExpression, FetchMode mode)
        {
            var associationPath = PropertyUtil.ExtractPropertyName(associationPropertyExpression);

            criteria.SetFetchMode(associationPath, mode);
            return(criteria);
        }
        public Entity_Company getCompanyById(long compId)
        {
            Utility.logFile(Constant.METHOD_ENTER + Utility.getCurrentMethodName(1) + "(CompanyManagerImpl)", null, Constant.LOGTYPE_INFO);
            DetachedCriteria criteria = DetachedCriteria.For <Entity_Company>();

            criteria.Add(Restrictions.Eq("companyId", compId));
            criteria.SetFetchMode("compDetailsObjList", NHibernate.FetchMode.Eager);//left outer join

            IList list = persistence.findByCriteria(criteria);

            if (list.Count > 0)
            {
                return((Entity_Company)list[0]);
            }
            else
            {
                return(null);
            }
        }
 public ICriteria SetFetchMode(string associationPath, FetchMode mode)
 {
     return(detachedCriteria.SetFetchMode(associationPath, mode).Adapt(session));
 }
Exemple #4
0
 public static DetachedCriteria SetFetchMode <T>(this DetachedCriteria criteria, Expression <Func <T, object> > expression, FetchMode fetchmode)
 {
     return(criteria.SetFetchMode(Clr <T> .Name(expression), fetchmode));
 }