Good you figured it out. As you said, using DerivedTable two times and DynamicRelation should result in something like your scenario. Example:
Given this sql
UPDATE Orders
SET Freight = 5
FROM
(SELECT tmp.CustomerId FROM
(SELECT CustomerId
FROM Customers
WHERE Country = 'USA') tmp
) tmp2
INNER JOIN Orders o
ON tmp2.CustomerId = o.CustomerId
... this would be the code to reproduce it:
// tmp
var tmpFields = new ResultsetFields(1);
tmpFields.DefineField(CustomerFields.CustomerId, 0);
var tmpDefinition = new DerivedTableDefinition(
tmpFields, "tmp", new PredicateExpression(CustomerFields.Country == "USA"));
// tmp2
var relation = new DynamicRelation(tmpDefinition, JoinHint.Inner,
EntityType.OrderEntity, "o",
(new EntityField2(CustomerFieldIndex.CustomerId.ToString(), "tmp2", typeof(string))
.Equal(OrderFields.CustomerId.SetObjectAlias("o"))));
// tmp2
var tmp2Fields = new ResultsetFields(1);
tmp2Fields.DefineField(CustomerFields.CustomerId, 0, "CustomerId", "tmp");
var tmp2Definition = new DerivedTableDefinition(
tmp2Fields, "tmp2", null, new RelationCollection(relation));
// root relation
var rootRelation = new DynamicRelation(tmp2Definition);
var bucket = new RelationPredicateBucket();
bucket.Relations.Add(rootRelation);
// set
var newValues = new OrderEntity { Freight = 5m };
// update
using (var adapter = new DataAccessAdapter())
{
adapter.UpdateEntitiesDirectly(newValues, bucket);
}