Exemple #1
0
        public void Insert()
        {
            var affrows = 0;

            using (var conn = new SqlConnection(_connectString)) {
                var item = new TestConnectionExt {
                    title = "testinsert"
                };
                affrows = conn.Insert <TestConnectionExt>().AppendData(item).ExecuteAffrows();
                conn.Close();
            }
            Assert.Equal(1, affrows);
        }
Exemple #2
0
        public void Delete()
        {
            var affrows = 0;

            using (var conn = new SQLiteConnection(_connectString)) {
                var item = new TestConnectionExt {
                    title = "testdelete"
                };
                affrows = conn.Insert <TestConnectionExt>().AppendData(item).ExecuteAffrows();
                Assert.Equal(1, affrows);
                affrows = conn.Delete <TestConnectionExt>().Where(item).ExecuteAffrows();
                conn.Close();
            }
            Assert.Equal(1, affrows);
        }
Exemple #3
0
        public void Query()
        {
            var list    = new List <TestConnectionExt>();
            var affrows = 0;

            using (var conn = new SqlConnection(_connectString)) {
                var item = new TestConnectionExt {
                    title = "testquery"
                };
                affrows = conn.Insert <TestConnectionExt>().AppendData(item).ExecuteAffrows();
                Assert.Equal(1, affrows);
                list = conn.Query <TestConnectionExt>("select * from TestConnectionExt where id = @id", new { id = item.id });
                conn.Close();
            }
            Assert.Single(list);
        }
Exemple #4
0
        public void Select()
        {
            var list    = new List <TestConnectionExt>();
            var affrows = 0;

            using (var conn = new SqlConnection(_connectString)) {
                var item = new TestConnectionExt {
                    title = "testselect"
                };
                affrows = conn.Insert <TestConnectionExt>().AppendData(item).ExecuteAffrows();
                Assert.Equal(1, affrows);
                list = conn.Select <TestConnectionExt>().Where(a => a.id == item.id).ToList();
                conn.Close();
            }
            Assert.Single(list);
        }
Exemple #5
0
        public void Update()
        {
            var affrows = 0;

            using (var conn = new SqlConnection(_connectString)) {
                var item = new TestConnectionExt {
                    title = "testupdate"
                };
                affrows = conn.Insert <TestConnectionExt>().AppendData(item).ExecuteAffrows();
                Assert.Equal(1, affrows);
                item    = conn.Select <TestConnectionExt>().First();
                affrows = conn.Update <TestConnectionExt>().SetSource(item).Set(a => a.title, "testupdated").ExecuteAffrows();
                conn.Close();
            }
            Assert.Equal(1, affrows);
        }
Exemple #6
0
        public void InsertOrUpdate()
        {
            var affrows = 0;

            using (var conn = new SQLiteConnection(_connectString))
            {
                var item = new TestConnectionExt {
                    title = "testinsert"
                };
                affrows = conn.Insert <TestConnectionExt>().AppendData(item).ExecuteAffrows();
                Assert.Equal(1, affrows);
                item.title = "testinsertorupdate";
                var affrows2 = conn.InsertOrUpdate <TestConnectionExt>().SetSource(item).ExecuteAffrows();
                conn.Close();
            }
            Assert.Equal(1, affrows);
        }