Пример #1
0
        public IPage <Bill> FindDebitorBillsForUser(IPageable pageRequest, User user, bool?isSettled)
        {
            HibernateDelegate <IPage <Bill> > finder = delegate(ISession session) {
                Require.NotNull(pageRequest, "pageRequest");
                Require.NotNull(user, "user");

                /*Mitgliedschaften des Nutzers laden, da die Rechnungen gegen die Mitgliedschaft gehen*/
                QueryOver <UserGroupMembership, UserGroupMembership> userGroupMembershipSubQuery =
                    QueryOver.Of <UserGroupMembership>().Where(mem => mem.User == user).Select(mem => mem.Id);

                /*Subquery für die Rechnungen, bei denen der Nutzer Schuldner ist*/
                IQueryOver <Bill, Bill> queryOver = session.QueryOver <Bill>();
                queryOver.Right.JoinQueryOver <BillUserGroupDebitor>(bill => bill.UserGroupDebitors)
                .WithSubquery.WhereProperty(deb => deb.UserGroupMembership)
                .In(userGroupMembershipSubQuery);

                if (isSettled.HasValue)
                {
                    queryOver.And(bill => bill.IsSettled == isSettled.Value);
                }

                queryOver = queryOver.OrderBy(bill => bill.CreatedAt).Desc;

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

            return(HibernateTemplate.Execute(finder));
        }
Пример #2
0
        /// <summary>
        ///     Versuch über ein Detached Criteria die Where-Klauseln zu verarbeiten, damit es mit dem Order nicht zu
        ///     komplikationen kommt.
        /// </summary>
        protected virtual IPage <T> Find(IPageable pageable, Action <DetachedCriteria> criteriaBuilder, Action <ICriteria> ordersBuilder = null)
        {
            Require.NotNull(pageable, "pageable");
            Require.NotNull(criteriaBuilder, "criteriaBuilder");

            HibernateDelegate <IPage <T> > finder = delegate(ISession session) {
                DetachedCriteria whereCriteria = DetachedCriteria.For(typeof(T));
                criteriaBuilder(whereCriteria);
                whereCriteria.SetProjection(Projections.Property("Id"));

                ICriteria elementsCriteria = session.CreateCriteria(typeof(T));
                elementsCriteria.Add(Subqueries.PropertyIn("Id", whereCriteria));

                if (ordersBuilder != null)
                {
                    ordersBuilder(elementsCriteria);
                }
                ApplyPaging(pageable, elementsCriteria);

                ICriteria countCriteria = session.CreateCriteria(typeof(T));
                countCriteria.Add(Subqueries.PropertyIn("Id", whereCriteria));
                countCriteria.SetProjection(Projections.RowCountInt64());

                IFutureValue <long> futureTotalCount = countCriteria.FutureValue <long>();
                IEnumerable <T>     futureElements   = elementsCriteria.Future <T>();
                Page <T>            page             = new Page <T>(futureElements.ToList(), pageable, futureTotalCount.Value);
                return(page);
            };

            return(HibernateTemplate.Execute(finder));
        }
Пример #3
0
        /// <summary>
        ///     Versuch über ein Detached Criteria die Where-Klauseln zu verarbeiten, damit es mit dem Order nicht zu
        ///     komplikationen kommt.
        /// </summary>
        protected virtual IPage <T> Find(IPageable pageable, Action <IQueryOver <T, T> > criteriaBuilder, Action <IQueryOver <T, T> > ordersBuilder = null)
        {
            Require.NotNull(pageable, "pageable");
            Require.NotNull(criteriaBuilder, "criteriaBuilder");

            HibernateDelegate <IPage <T> > finder = delegate(ISession session) {
                IQueryOver <T, T> query = session.QueryOver <T>();
                criteriaBuilder(query);
                if (ordersBuilder != null)
                {
                    ordersBuilder(query);
                }

                IQueryOver <T, T> countQuery = session.QueryOver <T>();
                criteriaBuilder(countQuery);

                query.Skip(pageable.FirstItem);
                query.Take(pageable.PageSize);

                long            futureTotalCount = countQuery.RowCountInt64();
                IEnumerable <T> futureElements   = query.Future <T>();
                Page <T>        page             = new Page <T>(futureElements.ToList(), pageable, futureTotalCount);
                return(page);
            };

            return(HibernateTemplate.Execute(finder));
        }
Пример #4
0
        public IPage <UserGroupMembership> FindOtherMembershipsInUsersGroups(IPageable pageRequest, User user, IList <UserGroupMembershipType> membershipTypes = null)
        {
            Require.NotNull(pageRequest, "pageRequest");
            Require.NotNull(user, "user");

            HibernateDelegate <IPage <UserGroupMembership> > finder = delegate(ISession session) {
                IQueryOver <UserGroupMembership, UserGroupMembership> queryOver = session.QueryOver <UserGroupMembership>();
                /*Die Mitgliedschaften des Nutzers nicht!*/
                queryOver.Where(membership => membership.User != user);

                /*Nur die der Gruppen des Nutzers*/
                var userGroupQueryOver = QueryOver.Of <UserGroupMembership>().Where(mem => mem.User == user).And(mem => mem.MembershipType == UserGroupMembershipType.Administrator || mem.MembershipType == UserGroupMembershipType.Member).Select(mem => mem.UserGroup.Id);
                queryOver.WithSubquery.WhereProperty(membership => membership.UserGroup).In(userGroupQueryOver);

                if (membershipTypes != null && membershipTypes.Any())
                {
                    /*Einschränkung der Mitgliedschaften*/
                    queryOver.WhereRestrictionOn(memberShip => memberShip.MembershipType).IsIn(membershipTypes.ToArray());
                }

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

            return(HibernateTemplate.Execute(finder));
        }
Пример #5
0
        public IPage <PeanutParticipation> FindParticipationsOfUser(IPageable pageRequest, User forUser, DateTime from, DateTime to,
                                                                    IList <PeanutParticipationState> participationStates = null)
        {
            HibernateDelegate <IPage <PeanutParticipation> > finder = delegate(ISession session) {
                IQueryOver <PeanutParticipation, PeanutParticipation> queryOver = session.QueryOver <PeanutParticipation>();

                IQueryOver <PeanutParticipation, UserGroupMembership> joinUserGroupMembership =
                    queryOver.JoinQueryOver(participation => participation.UserGroupMembership);
                /*Nur für den Nutzer*/
                joinUserGroupMembership.Where(userGroupMembership => userGroupMembership.User == forUser);

                IQueryOver <PeanutParticipation, Peanut> joinPeanut = queryOver.JoinQueryOver(participation => participation.Peanut);
                joinPeanut
                /*Am oder nach dem ab Datum*/
                .And(peanut => peanut.Day >= from)
                .And(peanut => peanut.PeanutState != PeanutState.Canceled)
                /*Nicht nach dem To Datum*/
                .AndNot(peanut => peanut.Day > to);

                if (participationStates != null && participationStates.Any())
                {
                    /*Nur wenn die Teilnahme einen bestimmten Status hat.*/
                    queryOver.AndRestrictionOn(part => part.ParticipationState).IsIn(participationStates.ToArray());
                }

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

            return(HibernateTemplate.Execute(finder));
        }
Пример #6
0
        public IPage <Bill> FindDeclinedCreditorBillsByUser(PageRequest pageRequest, User user)
        {
            Require.NotNull(pageRequest, "pageRequest");
            Require.NotNull(user, "user");

            HibernateDelegate <IPage <Bill> > finder = delegate(ISession session) {
                /*Mitgliedschaften des Nutzers laden, da die Rechnungen gegen die Mitgliedschaft gehen*/
                QueryOver <UserGroupMembership, UserGroupMembership> userGroupMembershipSubQuery =
                    QueryOver.Of <UserGroupMembership>().Where(mem => mem.User == user).Select(mem => mem.Id);

                QueryOver <BillUserGroupDebitor, BillUserGroupDebitor> debitorSubQuery =
                    QueryOver.Of <BillUserGroupDebitor>().Where(deb => deb.BillAcceptState == BillAcceptState.Refused).Select(deb => deb.Id);
                IList <BillUserGroupDebitor> userGroupDebitorAlias = null;
                QueryOver <Bill, Bill>       debitorBillsSubquery  =
                    QueryOver.Of <Bill>()
                    .JoinAlias(bill => bill.UserGroupDebitors, () => userGroupDebitorAlias)
                    .WithSubquery.WhereExists(debitorSubQuery)
                    .Select(bill => bill.Id);

                IQueryOver <Bill, Bill> queryOver = session.QueryOver <Bill>();
                queryOver.Where(bill => bill.IsSettled == false);
                queryOver.WithSubquery.WhereProperty(bill => bill.Creditor).In(userGroupMembershipSubQuery);
                queryOver.WithSubquery.WhereProperty(x => x.Id).In(debitorBillsSubquery);

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

            return(HibernateTemplate.Execute(finder));
        }
Пример #7
0
        public IPage <Peanut> FindBilledPeanutsInGroup(IPageable pageRequest, UserGroup userGroup, DateTime?from = null, DateTime?to = null)
        {
            Require.NotNull(userGroup, "userGroup");
            Require.NotNull(pageRequest, "pageRequest");

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

                queryOver.JoinQueryOver <Bill>(peanut => peanut.Bills).Where(peanutBill => peanutBill.IsSettled && peanutBill.UserGroup == userGroup);
                queryOver.Where(peanut => peanut.UserGroup == userGroup);

                if (from.HasValue)
                {
                    queryOver.And(p => p.Day > from.Value);
                }

                if (to.HasValue)
                {
                    queryOver.And(p => p.Day <= to.Value);
                }

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

            return(HibernateTemplate.Execute(finder));
        }
Пример #8
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));
        }
Пример #9
0
        /// <summary>
        ///     Liefert <code>true</code>, wenn der Gruppe Nutzer (egal in welchem Verhältnis) zugeordnet sind, ansonsten
        ///     <code>false</code>.
        /// </summary>
        /// <param name="userGroup"></param>
        /// <returns></returns>
        public bool AreUsersAssigned(UserGroup userGroup)
        {
            Require.NotNull(userGroup, nameof(userGroup));

            HibernateDelegate <bool> findAssignedUserCount = delegate(ISession session) {
                return(session.QueryOver <UserGroupMembership>().Where(membership => membership.UserGroup == userGroup).RowCountInt64() > 0);
            };

            return(HibernateTemplate.Execute(findAssignedUserCount));
        }
Пример #10
0
        /// <summary>
        ///     Liefert die Anzahl aller Objekte.
        /// </summary>
        /// <returns>Anzahl der Objekte.</returns>
        public long GetCount()
        {
            HibernateDelegate <long> find = delegate(ISession session) {
                ICriteria criteria = session.CreateCriteria(typeof(T));
                criteria.SetProjection(Projections.RowCountInt64());
                return(criteria.UniqueResult <long>());
            };

            return(HibernateTemplate.Execute(find));
        }
Пример #11
0
        /// <summary>
        ///     Ruft alle abgelehnten Zahlungen für einen Nutzer ab.
        /// </summary>
        /// <param name="pageRequest"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public IPage <Payment> FindDeclinedPaymentsByUser(IPageable pageRequest, User user)
        {
            HibernateDelegate <IPage <Payment> > finder = delegate(ISession session) {
                IQueryOver <Payment, Payment> queryOver = session.QueryOver <Payment>();
                queryOver.Where(payment => payment.RequestSender == user).And(payment => payment.PaymentStatus == PaymentStatus.Declined);
                return(FindPage(queryOver, pageRequest));
            };

            return(HibernateTemplate.Execute(finder));
        }
Пример #12
0
        public IList <PeanutParticipationType> Find(UserGroup userGroup)
        {
            HibernateDelegate <IPage <PeanutParticipationType> > finder = delegate(ISession session)
            {
                IQueryOver <PeanutParticipationType, PeanutParticipationType> queryOver = session.QueryOver <PeanutParticipationType>();
                queryOver.Where(p => p.UserGroup.Id == userGroup.Id);
                return(FindPage(queryOver, PageRequest.All));
            };

            return(HibernateTemplate.Execute(finder).ToList());
        }
Пример #13
0
        /// <summary>
        ///     Sucht einen beantragten Nutzer anhand des Benutzernamen aus.
        /// </summary>
        /// <param name="userName">Benutzername</param>
        /// <returns></returns>
        public ProposedUser FindByUserName(string userName)
        {
            HibernateDelegate <ProposedUser> finder = delegate(ISession session) {
                ICriteria criteria = session.CreateCriteria(typeof(ProposedUser));
                criteria.Add(Restrictions.Eq(Objects.GetPropertyName <ProposedUser>(user => user.UserName), userName));

                ProposedUser userByUserName = criteria.UniqueResult <ProposedUser>();
                return(userByUserName);
            };

            return(HibernateTemplate.Execute(finder));
        }
Пример #14
0
        public User FindByPasswordResetCode(Guid guid)
        {
            HibernateDelegate <User> finder = delegate(ISession session) {
                ICriteria criteria = session.CreateCriteria(typeof(User));
                criteria.Add(Restrictions.Eq(Objects.GetPropertyName <User>(user => user.PasswordResetCode), guid));

                User userByPasswordResetCode = criteria.UniqueResult <User>();
                return(userByPasswordResetCode);
            };

            return(HibernateTemplate.Execute(finder));
        }
Пример #15
0
        public Peanut FindFromBill(Bill bill)
        {
            Require.NotNull(bill, "bill");

            HibernateDelegate <Peanut> finder = delegate(ISession session) {
                IQueryOver <Peanut, Peanut> queryOver = session.QueryOver <Peanut>();
                queryOver.JoinQueryOver <Bill>(peanut => peanut.Bills).Where(peanutBill => peanutBill.Id == bill.Id);
                return(queryOver.SingleOrDefault());
            };

            return(HibernateTemplate.Execute(finder));
        }
Пример #16
0
        /// <summary>
        ///     Sucht einen Nutzer anhand der BusinessId aus.
        /// </summary>
        /// <param name="businessId">BuisnessId</param>
        /// <returns></returns>
        public new User GetByBusinessId(Guid businessId)
        {
            HibernateDelegate <User> finder = delegate(ISession session) {
                ICriteria criteria = session.CreateCriteria(typeof(User));
                criteria.Add(Restrictions.Eq(Objects.GetPropertyName <User>(user => user.BusinessId), businessId));

                User userByBId = criteria.UniqueResult <User>();
                return(userByBId);
            };

            return(HibernateTemplate.Execute(finder));
        }
Пример #17
0
        /// <summary>
        ///     Gibt die Anzahl der freigeschalteten Makler aus.
        /// </summary>
        public int GetActiveUserCount()
        {
            HibernateDelegate <int> finder = delegate(ISession session) {
                ICriteria criteria = session.CreateCriteria(typeof(User));
                criteria.Add(Restrictions.Eq(Objects.GetPropertyName <User>(user => user.IsEnabled), true));

                IList <User> activeUsers = criteria.List <User>();
                return(activeUsers.Count);
            };

            return(HibernateTemplate.Execute(finder));
        }
Пример #18
0
        public IPage <BookingEntry> FindByAccount(IPageable pageRequest, Account account)
        {
            HibernateDelegate <IPage <BookingEntry> > finder = delegate(ISession session) {
                IQueryOver <BookingEntry, BookingEntry> queryOverBookingEntries = session.QueryOver <BookingEntry>();
                IQueryOver <BookingEntry, Booking>      joinBooking             = queryOverBookingEntries.JoinQueryOver(entry => entry.Booking).OrderBy(booking => booking.BookingDate).Desc;
                queryOverBookingEntries = queryOverBookingEntries.Where(entry => entry.Account == account);

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

            return(HibernateTemplate.Execute(finder));
        }
Пример #19
0
        /// <summary>
        ///     Sucht einen Nutzer anhand seiner Email
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        public User FindByEmail(string email)
        {
            HibernateDelegate <User> finder = delegate(ISession session) {
                ICriteria criteria = session.CreateCriteria(typeof(User));
                criteria.Add(Restrictions.Eq(Objects.GetPropertyName <User>(user => user.Email), email));

                User userByEmail = criteria.UniqueResult <User>();
                return(userByEmail);
            };

            return(HibernateTemplate.Execute(finder));
        }
Пример #20
0
        public IPage <UserGroup> FindUserGroupsWhereUserIsNoMember(IPageable pageRequest, User user)
        {
            Require.NotNull(pageRequest, "pageRequest");
            Require.NotNull(user, "user");

            HibernateDelegate <IPage <UserGroup> > finder = delegate(ISession session) {
                var subQuery = QueryOver.Of <UserGroupMembership>().Where(membership => membership.User == user).Select(mem => mem.UserGroup.Id);
                IQueryOver <UserGroup, UserGroup> queryOver = session.QueryOver <UserGroup>();
                queryOver.WithSubquery.WhereProperty(g => g.Id).NotIn(subQuery);

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

            return(HibernateTemplate.Execute(finder));
        }
Пример #21
0
        /// <summary>
        ///     Liefert das Entity mit der entsprechenden BusinessId.
        /// </summary>
        /// <param name="businessId">die BusinessId</param>
        /// <returns>Das Entity</returns>
        /// <exception cref="ObjectNotFoundException">Wenn kein Entity mit der BusinessId existiert</exception>
        public T GetByBusinessId(Guid businessId)
        {
            HibernateDelegate <T> find = delegate(ISession session) {
                ICriteria criteria = session.CreateCriteria(typeof(T));
                criteria.Add(Restrictions.Eq("BusinessId", businessId));
                return(criteria.UniqueResult <T>());
            };
            T entity = HibernateTemplate.Execute(find);

            if (entity == null)
            {
                throw new ObjectNotFoundException(businessId, typeof(T));
            }
            return(entity);
        }
Пример #22
0
        public UserGroupMembership FindMembershipsByUserAndGroup(User user, UserGroup userGroup)
        {
            Require.NotNull(userGroup, "userGroup");
            Require.NotNull(user, "user");

            HibernateDelegate <UserGroupMembership> finder = delegate(ISession session) {
                IQueryOver <UserGroupMembership, UserGroupMembership> queryOver = session.QueryOver <UserGroupMembership>();
                queryOver
                /*Mitgliedschaft des Nutzers*/
                .Where(membership => membership.User == user)
                /*In der Gruppe*/
                .And(membership => membership.UserGroup == userGroup);

                return(queryOver.SingleOrDefault());
            };

            return(HibernateTemplate.Execute(finder));
        }
Пример #23
0
        public IPage <Peanut> FindAttendablePeanutsForUser(IPageable pageRequest, User user, DateTime from, DateTime to)
        {
            Require.NotNull(user, "user");
            Require.NotNull(pageRequest, "pageRequest");

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

                /*Die aktiven Gruppen des Nutzers*/
                IList <UserGroup> userGroups =
                    session.QueryOver <UserGroupMembership>()
                    .Where(mem => mem.User == user)
                    .And(
                        mem =>
                        mem.MembershipType == UserGroupMembershipType.Administrator ||
                        mem.MembershipType == UserGroupMembershipType.Member).Select(mem => mem.UserGroup)
                    .List <UserGroup>();

                IList <Peanut> attendedPeanuts =
                    session.QueryOver <PeanutParticipation>()
                    .Where(part => part.ParticipationState == PeanutParticipationState.Confirmed)
                    .JoinQueryOver(part => part.UserGroupMembership).Where(mem => mem.User == user)
                    .Select(part => part.Peanut)
                    .List <Peanut>();

                queryOver
                /*An bereits fixierten Tickets, kann sich kein neuer Teilnehmer anmelden.*/
                .Where(peanut => peanut.PeanutState == PeanutState.Scheduling)
                /*Am oder nach dem ab Datum*/
                .And(peanut => peanut.Day >= from)
                /*Nicht nach dem To Datum*/
                .AndNot(peanut => peanut.Day > to)
                /*Nur Peanuts aus den Gruppen des Nutzers*/
                .WhereRestrictionOn(peanut => peanut.UserGroup).IsIn(userGroups.ToList())
                /*Keine Peanuts an denen der Nutzer teilnimmt*/
                .WhereRestrictionOn(peanut => peanut.Id).Not.IsIn(attendedPeanuts.Select(p => p.Id).ToList());

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

            return(HibernateTemplate.Execute(finder));
        }
Пример #24
0
        public IPage <UserGroupMembership> FindMembershipsByUser(IPageable pageRequest, User user,
                                                                 IList <UserGroupMembershipType> membershipTypes = null)
        {
            Require.NotNull(pageRequest, "pageRequest");
            Require.NotNull(user, "user");

            HibernateDelegate <IPage <UserGroupMembership> > finder = delegate(ISession session) {
                IQueryOver <UserGroupMembership, UserGroupMembership> queryOver = session.QueryOver <UserGroupMembership>();
                queryOver.Where(membership => membership.User == user);

                if (membershipTypes != null && membershipTypes.Any())
                {
                    queryOver.WhereRestrictionOn(memberShip => memberShip.MembershipType).IsIn(membershipTypes.ToArray());
                }

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

            return(HibernateTemplate.Execute(finder));
        }
Пример #25
0
        /// <summary>
        ///     Liefert eine Liste mit Entities entsprechend der Pageinformationen
        ///     aus der Menge aller Entitäten.
        /// </summary>
        /// <param name="pageable">Beschreibung welche Menge der Entitäten zurückgeliefert werden.</param>
        /// <returns>Liste mit Entitäten.</returns>
        public virtual IPage <T> GetAll(IPageable pageable)
        {
            Require.NotNull(pageable, "pageable");

            HibernateDelegate <IPage <T> > finder = delegate(ISession session) {
                ICriteria elementsCriteria = session.CreateCriteria(typeof(T));
                elementsCriteria.AddOrder(Order.Asc("Id"));
                ApplyPaging(pageable, elementsCriteria);

                ICriteria countCriteria = session.CreateCriteria(typeof(T));
                countCriteria.SetProjection(Projections.RowCountInt64());

                IFutureValue <long> futureTotalCount = countCriteria.FutureValue <long>();
                IEnumerable <T>     futureElements   = elementsCriteria.Future <T>();
                Page <T>            page             = new Page <T>(futureElements.ToList(), pageable, futureTotalCount.Value);
                return(page);
            };

            return(HibernateTemplate.Execute(finder));
        }
Пример #26
0
        public IPage <Bill> FindPendingBillsByUser(IPageable pageRequest, User user)
        {
            Require.NotNull(pageRequest, "pageRequest");
            Require.NotNull(user, "user");

            HibernateDelegate <IPage <Bill> > finder = delegate(ISession session) {
                QueryOver <UserGroupMembership, UserGroupMembership> userGroupMembershipSubQuery =
                    QueryOver.Of <UserGroupMembership>().Where(mem => mem.User == user).Select(mem => mem.Id);

                /*Subquery für die Rechnungen, bei denen der Nutzer Schuldner ist*/
                QueryOver <BillUserGroupDebitor, BillUserGroupDebitor> debitorSubQuery =
                    QueryOver.Of <BillUserGroupDebitor>().WithSubquery.WhereProperty(deb => deb.UserGroupMembership).In(userGroupMembershipSubQuery).Select(deb => deb.Id);
                IList <BillUserGroupDebitor> userGroupAlias       = null;
                QueryOver <Bill, Bill>       debitorBillsSubquery =
                    QueryOver.Of <Bill>()
                    .JoinAlias(bill => bill.UserGroupDebitors, () => userGroupAlias)
                    .WithSubquery.WhereProperty(bill => bill.Creditor).In(debitorSubQuery)
                    .Select(bill => bill.Id);

                /*Subquery für die Rechnungen, bei denen der Nutzer Gläubiger ist*/
                QueryOver <Bill, Bill> creditorSubQuery =
                    QueryOver.Of <Bill>().WithSubquery.WhereProperty(bill => bill.Creditor).In(userGroupMembershipSubQuery).Select(bill => bill.Id);

                /*Nur Rechnungen, die die Subqueries erfüllen*/
                IQueryOver <Bill, Bill> queryOver = session.QueryOver <Bill>();
                queryOver
                .Where(Restrictions.Disjunction()
                       .Add(Subqueries.WhereProperty <Bill>(x => x.Id).In(debitorBillsSubquery))
                       .Add(Subqueries.WhereProperty <Bill>(x => x.Id).In(creditorSubQuery)));

                /*Rechnung muss offen sein.*/
                queryOver.And(bill => bill.IsSettled == false);

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

            return(HibernateTemplate.Execute(finder));
        }
Пример #27
0
 /// <summary>
 /// Execute the action specified by the delegate within a Session.
 /// </summary>
 /// <param name="del">The HibernateDelegate that specifies the action
 /// to perform.</param>
 /// <param name="exposeNativeSession">if set to <c>true</c> expose the native hibernate session to
 /// callback code.</param>
 /// <returns>a result object returned by the action, or <code>null</code>
 /// </returns>
 public object Execute(HibernateDelegate del, bool exposeNativeSession)
 {
     return Execute(new ExecuteHibernateCallbackUsingDelegate(del), true);
 }
Пример #28
0
 /// <summary>
 /// Execute the action specified by the given action object within a Session.
 /// </summary>
 /// <remarks>
 /// Application exceptions thrown by the action object get propagated to the
 /// caller (can only be unchecked). Hibernate exceptions are transformed into
 /// appropriate DAO ones. Allows for returning a result object, i.e. a domain
 /// object or a collection of domain objects.
 /// <p>Note: Callback code is not supposed to handle transactions itself!
 /// Use an appropriate transaction manager like HibernateTransactionManager.
 /// Generally, callback code must not touch any Session lifecycle methods,
 /// like close, disconnect, or reconnect, to let the template do its work.
 /// </p>
 /// </remarks>
 /// <param name="del">The delegate callback object that specifies the Hibernate action.</param>
 /// <returns>a result object returned by the action, or <code>null</code>
 /// </returns>
 /// <exception cref="DataAccessException">In case of Hibernate errors</exception>
 public object Execute(HibernateDelegate del)
 {
     return Execute(new ExecuteHibernateCallbackUsingDelegate(del));
 }
Пример #29
0
 public ExecuteHibernateCallbackUsingDelegate(HibernateDelegate d)
 {
     del = d;
 }
Пример #30
0
 public void Execute(HibernateDelegate action)
 {
     StockInDao.Execute(action);
 }