コード例 #1
0
        public void ShouldDoMultipleProjections()
        {
            var result = AuditReader().CreateQuery().ForEntitiesAtRevision(typeof(Car), 2)
                         .TraverseRelation("Owner", JoinType.InnerJoin)
                         .AddOrder(AuditEntity.Property("Age").Asc())
                         .AddProjection(AuditEntity.SelectEntity(false))
                         .TraverseRelation("Address", JoinType.InnerJoin)
                         .AddProjection(AuditEntity.Property("Number"))
                         .GetResultList();

            result.Count.Should().Be.EqualTo(3);

            var index0 = (object[])result[0];

            ((Person)index0[0]).Id.Should().Be.EqualTo(vwOwnerId);
            index0[1].Should().Be.EqualTo(5);

            var index1 = (object[])result[1];

            ((Person)index1[0]).Id.Should().Be.EqualTo(fordOwnerId);
            index1[1].Should().Be.EqualTo(5);

            var index2 = (object[])result[2];

            ((Person)index2[0]).Id.Should().Be.EqualTo(toyotaOwnerId);
            index2[1].Should().Be.EqualTo(20);
        }
コード例 #2
0
 public void ShouldDoProjectionOnTraversedPropertyDistinct()
 {
     AuditReader().CreateQuery().ForEntitiesAtRevision(typeof(Car), 2)
     .TraverseRelation("Owner", JoinType.InnerJoin)
     .TraverseRelation("Address", JoinType.InnerJoin)
     .AddProjection(AuditEntity.SelectEntity(true))
     .AddOrder(AuditEntity.Property("Number").Asc())
     .GetResultList <Address>().Select(x => x.Id)
     .Should().Have.SameSequenceAs(addressId1, addressId2);
 }