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(); } }
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(); } }
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(); } }); }
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); }