private string PrepareSqlWithInputKeys()
        {
            const string sqlPattern = @"
                {0}

                SELECT e.{1}, e.TflKey{2}
                FROM {3} e WITH (NOLOCK)
                INNER JOIN @KEYS k ON ({4});
            ";

            var builder = new StringBuilder();

            builder.AppendLine(_connection.WriteTemporaryTable("@KEYS", _key.WithInput()));
            builder.AppendLine(SqlTemplates.BatchInsertValues(50, "@KEYS", _key.WithInput(), _entity.InputKeys, _connection));

            var selectKeys = new FieldSqlWriter(_entity.PrimaryKey).AddDeleted(_entity).Alias(_connection.L, _connection.R).Write(", e.", false);
            var joinKeys   = new FieldSqlWriter(_entity.PrimaryKey).Input().Alias(_connection.L, _connection.R).Set("e", "k").Write(" AND ");

            return(string.Format(sqlPattern, builder, selectKeys, PrepareVersion(), _connection.Enclose(_entity.OutputName()), joinKeys));
        }