示例#1
0
        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) }
            }));
        }
示例#2
0
        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));
        }
示例#3
0
 public object Insert(string tableName, DbFields values) =>
 this.dbProvider.Insert(tableName, values);
示例#4
0
 public int Update(string tableName, DbFields values, string whereCondition, DbParameters parameters) =>
 this.dbProvider.Update(tableName, values, whereCondition, parameters);
示例#5
0
 public int Update(string tableName, DbFields values, string whereCondition) =>
 this.dbProvider.Update(tableName, values, whereCondition);