Пример #1
0
        /// <summary>
        /// Stateless Session 을 이용하여, <paramref name="criteria"/>에 해당하는 Entity를 조회합니다.
        /// </summary>
        public static IList <T> FindAllStateless <T>(this DetachedCriteria criteria, ISession session) where T : IDataObject
        {
            criteria.ShouldNotBeNull("criteria");
            criteria.ShouldNotBeNull("session");

            IList <T> result = null;

            NHWith.StatelessSessionNoTransaction(session,
                                                 stateless => { result = criteria.GetExecutableCriteria(stateless).List <T>(); });
            return(result ?? new List <T>());
        }
Пример #2
0
        /// <summary>
        /// 지정된 Criteria를 Criteri Batch 정보에 추가한다.
        /// </summary>
        /// <param name="criteria">criteria to add.</param>
        /// <returns>Current instance of CriteriaBatch</returns>
        public virtual CriteriaBatch Add(DetachedCriteria criteria)
        {
            criteria.ShouldNotBeNull("criteria");

            _currentIndex++;
            _criteriaList.Add(criteria);
            _currentCriteria = criteria;
            _collectionDelegates.Add(null);
            _uniqueResultDelegate.Add(null);
            _collectionAndCountDelegate.Add(null);

            return(this);
        }
Пример #3
0
        /// <summary>
        /// 지정된 Criteria를 Criteria Batch에 추가한다.
        /// </summary>
        /// <param name="criteria">criteria to look for</param>
        /// <param name="orders">order by</param>
        /// <returns>Current object</returns>
        public CriteriaBatch Add(DetachedCriteria criteria, params Order[] orders)
        {
            criteria.ShouldNotBeNull("criteria");

            if (orders != null)
            {
                foreach (Order order in orders)
                {
                    criteria.AddOrder(order);
                }
            }

            return(Add(criteria));
        }
Пример #4
0
        /// <summary>
        /// 세션에 사용될 ICriteria를 생성한다.
        /// </summary>
        /// <param name="theSession"></param>
        /// <param name="detachedCriteria"></param>
        /// <returns></returns>
        private static ICriteria CreateCriteria(ISession theSession, DetachedCriteria detachedCriteria)
        {
            theSession.ShouldNotBeNull("theSession");
            detachedCriteria.ShouldNotBeNull("detachedCriteria");

            var criteria = detachedCriteria.GetExecutableCriteria(theSession);

            var processDelegate = ProcessCriteria;

            if (processDelegate != null)
            {
                foreach (ProcessCriteriaDelegate process in processDelegate.GetInvocationList())
                {
                    criteria = process(criteria);
                }
            }
            return(criteria);
        }
Пример #5
0
        /// <summary>
        /// <paramref name="criteria"/>에 해당하는 엔티티가 존재하는지 검사합니다. 하나라도 있으면 True, 없으면 False
        /// </summary>
        public static bool ExistsStateless <T>(this DetachedCriteria criteria, ISession session) where T : IDataObject
        {
            criteria.ShouldNotBeNull("criteria");
            session.ShouldNotBeNull("session");

            var result = false;

            NHWith.StatelessSessionNoTransaction(session,
                                                 stateless => {
                result =
                    criteria
                    .SetMaxResults(1)
                    .GetExecutableCriteria(stateless)
                    .List <T>()
                    .Any();
            });

            return(result);
        }