Пример #1
0
        public void FlowQueryImplementorCreatesNewReferencesForUsedCollectionsWhenMorphing()
        {
            var query = new DummyQuery1(Session.CreateCriteria);

            query.XProject(x => new UserDto
            {
                Fullname = x.Firstname + " " + x.Lastname,
                Id       = x.Id
            });

            Assert.That(query.Mappings, Is.Not.Null);
            Assert.That(query.Mappings.Count, Is.EqualTo(2));

            IImmediateFlowQuery <UserEntity> immediate = query.Immediate();

            var morphable = immediate as IMorphableFlowQuery;

            Assert.That(morphable, Is.Not.Null);

            // ReSharper disable once PossibleNullReferenceException
            Assert.That(morphable.Mappings, Is.Not.Null);

            Assert.That(!ReferenceEquals(morphable.Mappings, query.Mappings));
            Assert.That(!ReferenceEquals(morphable.Orders, query.Orders));
            Assert.That(!ReferenceEquals(morphable.GroupBys, query.GroupBys));
            Assert.That(!ReferenceEquals(morphable.Joins, query.Joins));
            Assert.That(!ReferenceEquals(morphable.Locks, query.Locks));
            Assert.That(!ReferenceEquals(morphable.Aliases, query.Aliases));
        }
Пример #2
0
        public void MorphableQueryImplementorPopulatesMappingsIfSet()
        {
            var query = new DummyQuery1(Session.CreateCriteria);

            query.XProject(x => new UserDto
            {
                Fullname = x.Firstname + " " + x.Lastname,
                Id       = x.Id
            });

            Assert.That(query.Mappings, Is.Not.Null);
            Assert.That(query.Mappings.Count, Is.EqualTo(2));

            IImmediateFlowQuery <UserEntity> immediate = query.Immediate();

            var morphable = immediate as IMorphableFlowQuery;

            Assert.That(morphable, Is.Not.Null);

            // ReSharper disable once PossibleNullReferenceException
            Assert.That(morphable.Mappings, Is.Not.Null);

            Assert.That(morphable.Mappings.Count, Is.EqualTo(2));
        }