public static int Insert <T>(this DbAccessor db, object objParameters) { var mapping = new TableMapping(typeof(T)); mapping.FilterColumn(objParameters); ISqlBuilder sqlBuilder = new DefaultSqlBuilder(mapping); return(db.ExecuteNonQuery(sqlBuilder.BuildInsert(), objParameters)); }
public static int UpdateFields(this DbAccessor db, object objEntity, params string[] inclusiveFields) { List <string> lsInclusiveFields = new List <string>(); lsInclusiveFields.AddRange(inclusiveFields); var mapping = new TableMapping(objEntity.GetType()); foreach (var item in mapping.GetKeyColumns()) { lsInclusiveFields.Add(item.ColumnName); } mapping.FilterColumn(lsInclusiveFields.ToArray()); ISqlBuilder sqlBuilder = new DefaultSqlBuilder(mapping); return(db.ExecuteNonQuery(sqlBuilder.BuildUpdate(), objEntity)); }