public bool Create(BaseModel requestObject) { Dictionary <string, object> propDictionary = requestObject.GetPropertyDictionary(); DynamicParameters parameters = new DynamicParameters(); parameters = requestObject.BuildParameters(propDictionary); string sql = requestObject.GetInsertSql(propDictionary); using (var conn = _sqlConn.GetSqlConnection()) { conn.Execute(sql, parameters); } return(true); }
public bool Update(BaseModel requestObject) { Dictionary <string, object> propDictionary = requestObject.GetPropertyDictionary(); string sql = requestObject.GetUpdateSql(propDictionary); KeyValuePair <string, object> searchField = requestObject.GetSearchField(); propDictionary.Add(searchField.Key, searchField.Value); string whereSql = requestObject.GetWhereClause(searchField); sql += whereSql; DynamicParameters parameters = requestObject.BuildParameters(propDictionary); using (var conn = _sqlConn.GetSqlConnection()) { conn.Execute(sql, parameters); } return(true); }