Ejemplo n.º 1
0
        public void PropertyRefWithCompositeIdUpdateTest()
        {
            using (var spy = new SqlLogSpy())
            using (var session = OpenSession())
            using (session.BeginTransaction())
            {

                var direction1 = new Direction { Id1 = 1, Id2 = 1, GUID = Guid.NewGuid() };
                session.Save(direction1);
                
                var direction2 = new Direction { Id1 = 2, Id2 = 2, GUID = Guid.NewGuid() };
                session.Save(direction2);
                
                session.Flush();

                var directionReferrer = new DirectionReferrer
                                             {
                                                 GUID = Guid.NewGuid(),
                                                 Direction = direction1, 
                                             };

                session.Save(directionReferrer);

                directionReferrer.Direction = direction2;

                session.Update(directionReferrer);

                session.Flush();

                Console.WriteLine(spy.ToString());
                Assert.That(true);
            }
        }
Ejemplo n.º 2
0
        public void PropertyRefWithCompositeIdUpdateTest()
        {
            using (var spy = new SqlLogSpy())
                using (var session = OpenSession())
                    using (session.BeginTransaction())
                    {
                        var direction1 = new Direction {
                            Id1 = 1, Id2 = 1, GUID = Guid.NewGuid()
                        };
                        session.Save(direction1);

                        var direction2 = new Direction {
                            Id1 = 2, Id2 = 2, GUID = Guid.NewGuid()
                        };
                        session.Save(direction2);

                        session.Flush();

                        var directionReferrer = new DirectionReferrer
                        {
                            GUID      = Guid.NewGuid(),
                            Direction = direction1,
                        };

                        session.Save(directionReferrer);

                        directionReferrer.Direction = direction2;

                        session.Update(directionReferrer);

                        session.Flush();

                        Console.WriteLine(spy.ToString());
                        Assert.That(true);
                    }
        }