예제 #1
0
 public void Delete <T>(T obj) where T : class, IModel
 {
     using (var connection = new MySqlData.MySqlClient.MySqlConnection(_connection))
     {
         connection.Open();
         connection.Delete(obj);
         connection.Close();
     }
 }
예제 #2
0
 public void Delete <T>(string connection, T obj) where T : class, IModel
 {
     using (var c = new MySqlData.MySqlClient.MySqlConnection(connection))
     {
         c.Open();
         c.Delete(obj);
         c.Close();
     }
 }
예제 #3
0
 public async Task DeleteAsync <T>(string connection, T obj) where T : class, IModel
 {
     await Task.Run(() => {
         using (var c = new MySqlData.MySqlClient.MySqlConnection(connection))
         {
             c.Open();
             c.Delete(obj);
             c.Close();
         }
     });
 }
예제 #4
0
        public bool Delete <T>(T entityToDelete) where T : class
        {
            bool bResult = false;

            try
            {
                //using (var cn = new System.Data.SqlClient.SqlConnection(ConnStr))
                //{
                //    bResult = cn.Delete<T>(entityToDelete);
                //}

                if (_ProviderName == "System.Data.SqlClient")
                {
                    using (System.Data.SqlClient.SqlConnection cn = new System.Data.SqlClient.SqlConnection(ConnStr))
                    {
                        bResult = cn.Delete <T>(entityToDelete);
                    }
                }
                else if (_ProviderName == "MySql.Data.MySqlClient")
                {
                    using (MySql.Data.MySqlClient.MySqlConnection cn = new MySql.Data.MySqlClient.MySqlConnection(ConnStr))
                    {
                        bResult = cn.Delete <T>(entityToDelete);
                    }
                }
                else
                {
                    using (System.Data.SqlClient.SqlConnection cn = SqlClient)
                    {
                        bResult = cn.Delete <T>(entityToDelete);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(bResult);
        }