Example #1
0
        public int Save()
        {
            MySqlCommand cmd = GetSaveCommand(DbHelper.Connection);

            cmd.Connection.Open();
            try
            {
                DbHelper.SetContextInfo(cmd.Connection);
                Id = Convert.ToInt32(cmd.ExecuteScalar());
            }
            catch (Exception ex) { throw ex; }
            finally { cmd.Connection.Close(); }
            return(Id);
        }
Example #2
0
        public void SaveAll(bool waitForId = true)
        {
            MySqlConnection conn = DbHelper.Connection;

            try
            {
                conn.Open();
                DbHelper.SetContextInfo(conn);
                foreach (Tab tab in this)
                {
                    MySqlCommand cmd = tab.GetSaveCommand(conn);
                    tab.Id = Convert.ToInt32(cmd.ExecuteScalar());
                }
            }
            finally { conn.Close(); }
        }