public InsertBuilder(IDbConnection conn, T entity) : base(conn) { var properties = DefaultResolver.ResolveProperties(type, true); foreach (var p in properties) { var fieldName = DefaultResolver.ResolveColumnName(p); FieldBuilder.Append(FieldBuilder.Length > 0 ? $",{fieldName}" : fieldName); var paramterName = GetNewParamter(); SetParamter(paramterName, p.GetValue(entity, null)); ValueBuilder.Append(ValueBuilder.Length > 0 ? $",{paramterName}" : paramterName); } }
public UpdateBuilder(IDbConnection conn, T entity) : base(conn) { var properties = DefaultResolver.ResolveProperties(type, true); foreach (var p in properties) { var fieldName = DefaultResolver.ResolveColumnName(p); var paramterName = GetNewParamter(); var sql = $"{fieldName}={paramterName}"; SetFieldBuilder.Append(SetFieldBuilder.Length > 0 ? $",{sql}" : $" SET {sql}"); SetParamter(paramterName, p.GetValue(entity, null)); } AppendKeyWhere(entity); }
public string VisitMemberAccess(MemberExpression expression) { return(DefaultResolver.ResolveColumnName((PropertyInfo)expression.Member)); }