Beispiel #1
0
        private void LoadPage(int page)
        {
            using (var tx = StatelessSession.BeginTransaction())
            {
                var actions = StatelessSession.CreateCriteria <ToDoAction>()
                              .SetFirstResult(page * PageSize)
                              .SetMaxResults(PageSize)
                              .List <ToDoAction>();

                var total = StatelessSession.CreateCriteria <ToDoAction>()
                            .SetProjection(Projections.RowCount())
                            .UniqueResult <int>();

                this.NumberOfPages.Value = total / PageSize + (total % PageSize == 0 ? 0 : 1);
                this.Model = new Model
                {
                    Actions       = new ObservableCollection <ToDoAction>(actions),
                    NumberOfPages = NumberOfPages,
                    CurrentPage   = CurrentPage + 1
                };
                this.CurrentPage.Value = page;

                tx.Commit();
            }
        }
        public virtual IList <T> FindAll(NHibernateRepositorySortList sorts, int?pageIndex, int?pageSize, out int totalItems)
        {
            var criteria = IsStatelessSession
                                ? StatelessSession.CreateCriteria(typeof(T))
                                : Session.CreateCriteria(typeof(T));

            AddSortOrders(criteria, sorts);
            return(GetList(criteria, pageIndex, pageSize, out totalItems));
        }
        public virtual IList <T> FindByProperty(string property, object value, NHibernateRepositorySortList sorts, int?pageIndex, int?pageSize, out int totalItems)
        {
            var criteria = IsStatelessSession
                                ? StatelessSession.CreateCriteria(typeof(T))
                                : Session.CreateCriteria(typeof(T));

            criteria.Add(NHibernateCriterion.Restrictions.Eq(property, value));

            AddSortOrders(criteria, sorts);
            return(GetList(criteria, pageIndex, pageSize, out totalItems));
        }
Beispiel #4
0
        public List <T> GetAllStateless()
        {
            return(StatelessSession.CreateCriteria(persitentType).List <T>() as List <T>);

            //ICriteria criteria = Session.CreateCriteria(persitentType);

            ////foreach (ICriterion criterium in criterion)
            ////{
            ////  criteria.Add(criterium);
            ////}

            //return criteria.List<T>() as List<T>;
        }