protected override ISqlBuilder Update(MemberInitExpression expression, ISqlBuilder sqlBuilder) { var updates = new List <string>(); foreach (MemberAssignment memberAss in expression.Bindings) { var memberExp = memberAss.Expression; var property = memberAss.Member as PropertyInfo; if (property.IsKeyProperty(expression.Type)) { continue; } if (!property.IsDataConlumnProperty(expression.Type)) { continue; } MemberInfo member = memberAss.Member; //var tablAliax = GetTableAlias(memberExp, sqlBuilder); var columnName = $"{sqlBuilder.Formate(member.Name)}"; var value = TryGetExpreesionValue(memberExp); string sqlParamName = sqlBuilder.SetSqlParameter(value); updates.Add($"{columnName} = {sqlParamName}"); } sqlBuilder.AppendUpdateSql($"{string.Join(",", updates)} "); return(sqlBuilder); }
/// <summary> /// update /// </summary> /// <param name="expression"></param> /// <returns></returns> public IUpdateQueryAble <T> Update(Expression <Func <T> > expression) { Check.Argument.IsNotNull(expression, nameof(expression)); _SqlBuilder.SetSqlCommandType(SqlCommandType.Update); _SqlBuilder.AppendUpdateSql($"UPDATE {_MainTableName} SET "); SqlVistorProvider.Update(expression.Body, _SqlBuilder); return(new UpdateQueryAble <T>(_SqlBuilder, _DapperKitProvider)); }