Beispiel #1
0
        public void TestUpdateCollection()
        {
            using (Model.Context db = new Model.Context("mdbConnectionString"))
            {
                Author a = new Author();
                a.Username = "******";
                a.Posts    = new List <Post>();

                Post p = new Post();
                p.Content = "Test post content";

                Post pp = new Post();
                pp.Content = "Another test content";

                a.Posts.Add(p);
                a.Posts.Add(pp);

                db.InsertOnSubmit <Author>(a); // assume it works, tested on other methods
                db.SubmitChanges();

                a.Posts.First().Content = "Last content";
                db.UpdateOnSubmit <Author>(a, Context.CascadeStyle.All);
                db.SubmitChanges();

                Post compare = db.Connection.Query <Post>("SELECT * FROM Posts WHERE Id = " + a.Posts.First().Id).FirstOrDefault();

                Assert.AreEqual(compare.Content, a.Posts.First().Content);

                db.DeleteOnSubmit <Author>(a, Context.CascadeStyle.All);
                db.SubmitChanges();
            }
        }
Beispiel #2
0
        public void TestUpdateSimple()
        {
            using (Model.Context db = new Model.Context("mdbConnectionString"))
            {
                Note n = new Note();
                n.Content  = "Prueba";
                n.Created  = DateTime.UtcNow.Date;
                n.Modified = DateTime.UtcNow.Date;

                db.InsertOnSubmit <Note>(n);
                db.SubmitChanges();

                n.Content = "Test";
                db.UpdateOnSubmit <Note>(n);
                db.SubmitChanges();

                Note newNote = db.Connection.Query <Note>("SELECT * FROM Notes WHERE Codigo = " + n.Codigo).FirstOrDefault();

                Assert.AreEqual(newNote.Content, "Test");

                db.DeleteOnSubmit <Note>(newNote);
                db.SubmitChanges();
            }
        }
        public void TestUpdateSimple()
        {
            using (Model.Context db = new Model.Context("mdbConnectionString"))
            {
                Note n = new Note();
                n.Content = "Prueba";
                n.Created = DateTime.UtcNow.Date;
                n.Modified = DateTime.UtcNow.Date;

                db.InsertOnSubmit<Note>(n);
                db.SubmitChanges();

                n.Content = "Test";
                db.UpdateOnSubmit<Note>(n);
                db.SubmitChanges();

                Note newNote = db.Connection.Query<Note>("SELECT * FROM Notes WHERE Codigo = " + n.Codigo).FirstOrDefault();

                Assert.AreEqual(newNote.Content, "Test");

                db.DeleteOnSubmit<Note>(newNote);
                db.SubmitChanges();
            }
        }
        public void TestUpdateCollection()
        {
            using (Model.Context db = new Model.Context("mdbConnectionString"))
            {
                Author a = new Author();
                a.Username = "******";
                a.Posts = new List<Post>();

                Post p = new Post();
                p.Content = "Test post content";

                Post pp = new Post();
                pp.Content = "Another test content";

                a.Posts.Add(p);
                a.Posts.Add(pp);

                db.InsertOnSubmit<Author>(a); // assume it works, tested on other methods
                db.SubmitChanges();

                a.Posts.First().Content = "Last content";
                db.UpdateOnSubmit<Author>(a, Context.CascadeStyle.All);
                db.SubmitChanges();

                Post compare = db.Connection.Query<Post>("SELECT * FROM Posts WHERE Id = " + a.Posts.First().Id).FirstOrDefault();

                Assert.AreEqual(compare.Content, a.Posts.First().Content);

                db.DeleteOnSubmit<Author>(a, Context.CascadeStyle.All);
                db.SubmitChanges();
            }
        }