Exemplo n.º 1
0
        public bool Create(Section section, out int id)
        {
            using (var cn = Connection)
            {
                using (var transaction = new TransactionScope())
                {
                    cn.Open();

                    var success = true;
                    id = -1;

                    var sql = "INSERT INTO `pagesections` (`Name`) VALUES (@Name);";

                    success = cn.Execute(sql, section) > 0;

                    var newId = cn.Query<ulong>("SELECT CAST(LAST_INSERT_ID() AS UNSIGNED INTEGER);").SingleOrDefault();
                    id = Convert.ToInt32(newId);

                    transaction.Complete();

                    return success;
                }
            }
        }
Exemplo n.º 2
0
        public bool Update(Section section)
        {
            using (var cn = Connection)
            {
                var sql = "UPDATE `pagesections` SET `Name`=@Name WHERE `id`=@id;";

                return cn.Execute(sql, section) > 0;
            }
        }
Exemplo n.º 3
0
        public bool Delete(Section section)
        {
            using (var cn = Connection)
            {
                var sql = "DELETE FROM `pagesections` WHERE `id`=@id;";

                return cn.Execute(sql, section) > 0;
            }
        }