예제 #1
0
        public virtual void TestDelayedCopy()
        {
            IDelayedFlowQuery <UserEntity> query1 = Query <UserEntity>()
                                                    .Delayed();

            IDelayedFlowQuery <UserEntity> query2 = query1.Copy()
                                                    .Where(x => x.IsOnline);

            FlowQuerySelection <UserEntity> users1 = query1.Select();

            FlowQuerySelection <UserEntity> users2 = query2.Select();

            Assert.That(users1.Count(), Is.EqualTo(4));
            Assert.That(users2.Count(), Is.EqualTo(3));
        }
        public void Given_DelayedQueryWithModelBasedOrders_When_LaterUsedAsSubquery_IsSortedByAppropriateSourceProjection()
        {
            IDelayedFlowQuery <UserEntity> query = Query <UserEntity>()
                                                   .OrderBy <UserDto>(x => x.SomeValue)
                                                   .Delayed();

            FlowQuerySelection <UserDto> allUsers = query
                                                    .Select(Projection);

            IDetachedFlowQuery <UserEntity> subquery = query
                                                       .Detached()
                                                       .Limit(2, 1)
                                                       .Select(x => x.Id);

            FlowQuerySelection <UserDto> subsetOfUsers = Query <UserEntity>()
                                                         .Delayed()
                                                         .Where(x => x.Id, NHibernate.FlowQuery.Is.In(subquery))
                                                         .Select(Projection);

            Assert.That(allUsers.Count(), Is.EqualTo(4));
            Assert.That(subsetOfUsers.Count(), Is.EqualTo(2));
            Assert.That(subsetOfUsers.ElementAt(0).SomeValue, Is.EqualTo("Lars Wilk"));
            Assert.That(subsetOfUsers.ElementAt(1).SomeValue, Is.EqualTo("Lotta Brak"));
        }