PersonCollection PersonColl = new PersonCollection();
SELECT Per.Name,Per.Age,Addr.City,Addr.Zip
If you want to fetch fields from more than one table/entity then you should use a DynamicList.
Anyway:
IRelationCollection relationsToUse = new RelationCollection();
relationsToUse.Add(PersonEntity.Relations.PersonAddressEntityUsingPersonId);
You haven't specified the outer join, please look for overloads of the above Add() methods, to specify the join hint.
FROM Person Per,
Address Addr
Are you joining to PersonAddress or to Address?
IPredicateExpression subQueryFilter = new PredicateExpression();
subQueryFilter.Add(
new FieldCompareExpressionPredicate(
PersonFields.PersonId.SetObjectAlias("person_inner"),
ComparisonOperator.Equal, new Expression(PersonFields.PersonId)));
subQueryFilter.Add(
new FieldCompareExpressionPredicate(
PaymentFields.PersonId,
ComparisonOperator.Equal, new Expression(PersonFields.PersonId)))
IPredicateExpression filter = new PredicateExpression();
filter.AddWithAnd(
new FieldCompareSetPredicate(
PersonFields.PersonId,
PersonFields.PersonId,
SetOperator.In,
subQueryFilter));
1- You didn't add a JOIN/Relation to Payment as You are filtering on it.
2- You should have used an alias in the FieldCOmapreSetPredicate as follows:
filter.AddWithAnd(
new FieldCompareSetPredicate(
PersonFields.PersonId,
PersonFields.PersonId.SetObjectAlias("person_inner"),
SetOperator.In,
subQueryFilter));