예제 #1
0
        //DetachedCriteria
        public IEnumerable <T> Fetch(Framework.Common.NHibernate.CriterionRequest <T> Criterion)
        {
            ICriteria criterias = this.Session.CreateCriteria <T>();

            if (Criterion.Criterias != null)
            {
                foreach (var exp in Criterion.Criterias)
                {
                    criterias.Add(exp.Compile().Invoke());
                }
            }
            if (Criterion.Associations != null)
            {
                foreach (var aexp in Criterion.Associations)
                {
                    criterias.CreateCriteria(aexp.AssociationPath, aexp.Alias);
                    if (aexp.Criterias != null)
                    {
                        foreach (var child in aexp.Criterias)
                        {
                            criterias.Add(child.Compile().Invoke());
                        }
                    }
                }
            }
            ICriteria totalcriteria = criterias.Clone() as ICriteria;

            Criterion.Totals = totalcriteria.SetProjection(Projections.RowCount()).UniqueResult <int>();
            if (Criterion.Orders != null)
            {
                foreach (var order in Criterion.Orders)
                {
                    criterias.AddOrder(order.Compile().Invoke());
                }
            }
            if (Criterion.Associations != null)
            {
                foreach (var aexp in Criterion.Associations)
                {
                    if (aexp.Orders != null)
                    {
                        foreach (var child in aexp.Orders)
                        {
                            criterias.AddOrder(child.Compile().Invoke());
                        }
                    }
                }
            }
            criterias.SetFirstResult((Criterion.CurrentPage - 1) * Criterion.PageSize)
            .SetMaxResults(Criterion.PageSize);
            Criterion.DataList = criterias.List <T>();
            return(Criterion.DataList);
        }
예제 #2
0
 public IEnumerable <Entities.SysUser> GetAccounts(Framework.Common.NHibernate.CriterionRequest <Entities.SysUser> Criterion)
 {
     return(service.Fetch(Criterion));
 }
예제 #3
0
 public IEnumerable <Entities.SysPositionCategory> Fetch(Framework.Common.NHibernate.CriterionRequest <Entities.SysPositionCategory> Criterion)
 {
     return(this.respository.Fetch(Criterion));
 }
예제 #4
0
 public IEnumerable <Entities.SysDepartment> GetDepartments(Framework.Common.NHibernate.CriterionRequest <Entities.SysDepartment> Criterion)
 {
     return(repository.Fetch(Criterion));
 }