public static int Delete <T>(IConnection conn, ICriteria <T> criteria) where T : EntityBase, new() { SQLBuilder sql = new TSQLBuilder(); string sqlStatement = string.Empty; try { sql.BuildDelete(SQLSyntax.Delete, (new T()).Mapping); Dictionary <SQLSyntax, string> sqlSyntaxDictionary = TranslateCriteria <T>(criteria); foreach (var item in sqlSyntaxDictionary) { sql.BuildDelete(item.Key, item.Value); } sqlStatement = sql.Delete; return(conn.ExecuteNonQuery(sqlStatement)); } catch (Exception ex) { throw new Exception(ex.Message + "{" + sqlStatement + "}"); } finally { } }
public static int Delete <T>(IConnection conn, T entity) where T : EntityBase { SQLBuilder sql = new TSQLBuilder(); string sqlStatement = string.Empty; try { sql.BuildDelete(SQLSyntax.Delete, entity.Mapping); sql.BuildDelete(SQLSyntax.Where, entity.KeyCondition); //if (entity.NeedAudit) Audit<T>(conn, entity, SQLSyntax.Delete); sqlStatement = sql.Delete; return(conn.ExecuteNonQuery(sqlStatement)); } catch (Exception ex) { throw new Exception(ex.Message + "{" + sqlStatement + "}"); } finally { } }