In order to clarity I've rewroted your query:
SELECT
*
FROM
[Table1]
WHERE
(
SELECT
COUNT (*)
FROM
[Table1] [tbl1]
INNER JOIN
[Table2] [tbl2]
ON ([tbl2].[Id]=[tbl2].[IdOrden])
WHERE
[tbl2].[IdOrden] = [Table1].[Id]
) >=1
And here is the corresponding c# code:
//collection to be fetched
EntityCollection<Table1Entity> table1Collection = new EntityCollection<Table1Entity>(new Table1EntityFactory());
//the aliases here is the most important part
IRelationCollection subRelations = new RelationCollection();
subRelations.Add(Table1Entity.Relations.Table2EntityUsingNumericKey, " tbl1", "tbl2", JoinHint.Inner); //use new EntityRelation(... if the relation doesn't exists
IPredicateExpression subFilter = new PredicateExpression();
subFilter.Add(new FieldCompareExpressionPredicate(Table1Fields.Employee, null, ComparisonOperator.Equal, new Expression(Table1Fields.Employee), "tbl1"));
EntityField2 countField = new EntityField2("countField",
new ScalarQueryExpression(Table1Fields.Id.SetAggregateFunction(AggregateFunction.Count),
subFilter,subRelations));
IRelationPredicateBucket filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(new FieldCompareValuePredicate(countField,null,ComparisonOperator.GreaterEqual,1));
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.FetchEntityCollection(table1Collection, filter);
}
I've left the other subFilters out, just add them in the subFilter object.