public int Update <T>(string tableName, T obj, string idField, params string[] ignoreFields) { var dbFields = new DbFields(); foreach (var property in obj.GetType().GetProperties()) { if (property.Name != idField && (ignoreFields == null || !ignoreFields.Contains(property.Name, StringComparer.OrdinalIgnoreCase))) { var value = property.GetValue(obj, null); if (value != null) { dbFields.Add(property.Name, value); } } } return(this.dbProvider.Update( tableName, dbFields, $"{idField} = @{idField}", new DbParameters() { { idField, obj.GetType().GetProperty(idField).GetValue(obj, null) } })); }
public object Insert <T>(string tableName, T obj, string uuidField, params string[] ignoreFields) { var dbFields = new DbFields(); foreach (var property in obj.GetType().GetProperties()) { if (ignoreFields == null || !ignoreFields.Contains(property.Name, StringComparer.OrdinalIgnoreCase)) { var value = property.GetValue(obj, null); if (value != null) { dbFields.Add(property.Name, value); } } } return(this.dbProvider.Insert( tableName, dbFields, string.IsNullOrWhiteSpace(uuidField) ? null : uuidField)); }
public object Insert(string tableName, DbFields values) => this.dbProvider.Insert(tableName, values);
public int Update(string tableName, DbFields values, string whereCondition, DbParameters parameters) => this.dbProvider.Update(tableName, values, whereCondition, parameters);
public int Update(string tableName, DbFields values, string whereCondition) => this.dbProvider.Update(tableName, values, whereCondition);