Inheritance: EmbeddedEntity
Example #1
0
        public void UpdateEfieConditional()
        {
            using (Transaction tr = new Transaction())
            {
                SongEntity song = new SongEntity
                {
                    Name = "Mana Mana",
                    Duration = TimeSpan.FromSeconds(184),
                };


                int count = Database.Query<AlbumEntity>().UnsafeUpdate()
                    .Set(a => a.BonusTrack, a => (int)a.Id % 2 == 0 ? song : null)
                .Execute();

                Assert.IsTrue(Database.Query<AlbumEntity>().All(a => (int)a.Id % 2 == 0 ? a.BonusTrack.Name == "Mana Mana" : a.BonusTrack.Name == null));

                //tr.Commit();
            }
        }
Example #2
0
        public void UpdateEfie()
        {
            using (Transaction tr = new Transaction())
            {
                SongEntity song = new SongEntity
                {
                    Name = "Mana Mana",
                    Duration = TimeSpan.FromSeconds(184),
                };


                int count = Database.Query<AlbumEntity>().UnsafeUpdate()
                .Set(a => a.BonusTrack, a => song)
                .Execute();

                Assert.IsFalse(Database.Query<AlbumEntity>().Any(a => a.BonusTrack == null));
                Assert.AreEqual(Database.Query<AlbumEntity>().Select(a => a.BonusTrack.Name).Distinct().SingleEx(), "Mana Mana");

                //tr.Commit();
            }

        }