You should use DBFunctionCall, set this expression on a field and pass it in the sortclause:
// define the field you want to retrieve
ResultsetFields fields = new ResultsetFields(1);
fields.DefineField(CustomerFields.ContactName, 0);
// The Sorter
EntityField2 sortField = new EntityField2("theLen", new DbFunctionCall("LEN", new object[] { CustomerFields.ContactName }));
SortClause lenSortClause = new SortClause(sortField, null, SortOperator.Ascending);
// this is important, setting this to false will emit our custom expression at ORDER BY clause
lenSortClause.EmitAliasForExpressionAggregateField = false;
SortExpression sorter = new SortExpression(lenSortClause);
// fetch the resuts
DataTable results = new DataTable();
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.FetchTypedList(fields, results, null, 0, sorter, true);
}
You also can do that using EntityCollection instead of DynamicList.
Hope helpful