Example #1
0
        public void ExpandSubCollectionWithCompositeID()
        {
            using (ISession s = OpenSession())
			using (var tx = s.BeginTransaction())
            {

                var jenny = new Mum { Name = "Jenny" };
                s.Save(jenny);
                var benny = new Dad { Name = "Benny" };
                s.Save(benny);
                var lenny = new Dad { Name = "Lenny" };
                s.Save(lenny);
                var jimmy = new FriendOfTheFamily { Name = "Jimmy", Id = new MumAndDadId { MumId = jenny.Id, DadId = benny.Id } };
                s.Save(jimmy);
                var timmy = new FriendOfTheFamily { Name = "Timmy", Id = new MumAndDadId { MumId = jenny.Id, DadId = lenny.Id } };
                s.Save(timmy);

                tx.Commit();
            }

            using (var s = OpenSession())
            {
                var result=s.Query<Mum>().Select(x => new { x, x.Friends }).ToList();
                Assert.That(result.Count, Is.EqualTo(1));
                Assert.That(result[0].x.Friends, Is.EquivalentTo(result[0].Friends));
            }
        }
Example #2
0
        public void ExpandSubCollectionWithEmbeddedCompositeID()
        {
            using (ISession s = OpenSession())
            {

                var jenny = new Mum { Name = "Jenny" };
                s.Save(jenny);
                var benny = new Dad { Name = "Benny" };
                s.Save(benny);
                var lenny = new Dad { Name = "Lenny" };
                s.Save(lenny);
                var jimmy = new Kid { Name = "Jimmy", MumId = jenny.Id, DadId = benny.Id };
                s.Save(jimmy);
                var timmy = new Kid { Name = "Timmy", MumId = jenny.Id, DadId = lenny.Id };
                s.Save(timmy);
                s.Flush();
            }

            using (var s = OpenSession())
            {
                var result=s.Query<Mum>().Select(x => new { x, x.Kids }).ToList();
                Assert.That(result.Count, Is.EqualTo(1));
                Assert.That(result[0].x.Kids, Is.EquivalentTo(result[0].Kids));
            }
        }
Example #3
0
        public void ExpandSubCollectionWithEmbeddedCompositeID()
        {
            using (ISession s = OpenSession())
            {
                var jenny = new Mum {
                    Name = "Jenny"
                };
                s.Save(jenny);
                var benny = new Dad {
                    Name = "Benny"
                };
                s.Save(benny);
                var lenny = new Dad {
                    Name = "Lenny"
                };
                s.Save(lenny);
                var jimmy = new Kid {
                    Name = "Jimmy", MumId = jenny.Id, DadId = benny.Id
                };
                s.Save(jimmy);
                var timmy = new Kid {
                    Name = "Timmy", MumId = jenny.Id, DadId = lenny.Id
                };
                s.Save(timmy);
                s.Flush();
            }

            using (var s = OpenSession())
            {
                var result = s.Query <Mum>().Select(x => new { x, x.Kids }).ToList();
                Assert.That(result.Count, Is.EqualTo(1));
                Assert.That(result[0].x.Kids, Is.EquivalentTo(result[0].Kids));
            }
        }
Example #4
0
        public async Task ExpandSubCollectionWithCompositeIDAsync()
        {
            using (ISession s = OpenSession())
                using (var tx = s.BeginTransaction())
                {
                    var jenny = new Mum {
                        Name = "Jenny"
                    };
                    await(s.SaveAsync(jenny));
                    var benny = new Dad {
                        Name = "Benny"
                    };
                    await(s.SaveAsync(benny));
                    var lenny = new Dad {
                        Name = "Lenny"
                    };
                    await(s.SaveAsync(lenny));
                    var jimmy = new FriendOfTheFamily {
                        Name = "Jimmy", Id = new MumAndDadId {
                            MumId = jenny.Id, DadId = benny.Id
                        }
                    };
                    await(s.SaveAsync(jimmy));
                    var timmy = new FriendOfTheFamily {
                        Name = "Timmy", Id = new MumAndDadId {
                            MumId = jenny.Id, DadId = lenny.Id
                        }
                    };
                    await(s.SaveAsync(timmy));

                    await(tx.CommitAsync());
                }

            using (var s = OpenSession())
            {
                var result = await(s.Query <Mum>().Select(x => new { x, x.Friends }).ToListAsync());
                Assert.That(result.Count, Is.EqualTo(1));
                Assert.That(result[0].x.Friends, Is.EquivalentTo(result[0].Friends));
            }
        }