Example #1
0
        public IPage <Peanut> FindPeanutsInGroups(IPageable pageRequest, IList <UserGroup> userGroups, DateTime?from, DateTime?to)
        {
            Require.NotNull(userGroups, "userGroups");
            Require.NotNull(pageRequest, "pageRequest");

            HibernateDelegate <IPage <Peanut> > finder = delegate(ISession session) {
                IQueryOver <Peanut, Peanut> queryOver = session.QueryOver <Peanut>();

                queryOver.WhereRestrictionOn(p => p.UserGroup).IsIn(userGroups.ToList());
                if (from != null)
                {
                    /*Am oder nach dem ab Datum*/
                    queryOver.And(peanut => peanut.Day >= from);
                }
                if (to != null)
                {
                    /*Nicht nach dem To Datum*/
                    queryOver.AndNot(peanut => peanut.Day > to);
                }

                return(FindPage(queryOver, pageRequest));
            };

            return(HibernateTemplate.Execute(finder));
        }
 public IQueryOver <TRoot, TSubType> AndNot(Expression <Func <TSubType, bool> > expression)
 {
     MainQuery.AndNot(expression);
     return(this);
 }