protected override ChangeResult executeInternal(SQLDatabaseConnection conn) { if (_conditions == null || !_conditions.Any()) { return new ChangeResult() { Exception = new Exception("Command without conditions.") } } ; if (_specificFields == null || _specificFields.Count <= 0) { return new ChangeResult() { Exception = new Exception("Command without set's.") } } ; var tableName = typeof(T).Name; StringBuilder builder = new StringBuilder(); var parameters = SqlCommandBuilder.BuildUpdateSetStatement <T>(ref builder, (from f in _specificFields select f.Value).ToArray(), _pkProperty, _properties); builder.Append($" WHERE [{_pkProperty.Name}] IN (SELECT [{_pkProperty.Name}] FROM [{tableName}] {base.getWhereClause()}) "); var sqlParameters = getWhereParameters() ?? new Microsoft.Data.SqlClient.SqlParameter[0]; var additionalParameters = parameters.Select(p => new Microsoft.Data.SqlClient.SqlParameter(p.Item1, SqlCommandBuilder.GetSqlRawValue(p.Item3, p.Item2)) { SqlDbType = MicroORM.Core.SqlCommandBuilder.GetSqlFieldType(p.Item3) }).ToList(); if (additionalParameters.Count > 0) { sqlParameters = sqlParameters.Concat(additionalParameters).ToArray(); } int commandResult = conn.ExecuteCommand(builder.ToString(), getTimeout(), sqlParameters); ResetChanges(); return(new ChangeResult() { UpdatedCount = commandResult, AffectedCount = commandResult }); } } }