Exemplo n.º 1
0
        public void UpdateEfieConditional()
        {
            using (Transaction tr = new Transaction())
            {
                SongDN song = new SongDN
                {
                    Name = "Mana Mana",
                    Duration = TimeSpan.FromSeconds(184),
                };


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

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

                //tr.Commit();
            }
        }
Exemplo n.º 2
0
        public void UpdateEfie()
        {
            using (Transaction tr = new Transaction())
            {
                SongDN song = new SongDN
                {
                    Name = "Mana Mana",
                    Duration = TimeSpan.FromSeconds(184),
                };


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

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

                //tr.Commit();
            }

        }