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