I've done it a bit differently, with an extra join, as you specify a join between two tables without a relation (which is doable in SQL, but not in LLBLGen Pro)
It's selfservicing, but adapter is pretty the same. I've commented the code abit so you see teh connection between the sql and the predicates. I haven't tested it in full as I don't have a database setup like your situation, though it should give the same results.
ResultsetFields fields = new ResultsetFields(1);
fields.DefineField(PageFieldIndex.PageID, 0, "PageID");
// Page INNER JOIN PropertyValuesForPage p1 ON Page.PageID = p1.PageID
// INNER JOIN PropertyValuesForPage p2 ON Page.PageID = p2.PageID
RelationCollection relations = new RelationCollection();
relations.Add(PageEntity.Relations.PropertyValuesForPageEntityUsingPageID, "p1");
relations.Add(PageEntity.Relations.PropertyValuesForPageEntityUsingPageID, "p2");
PredicateExpression filter = new PredicateExpression();
// Add:
// p1.Property_Name = 'Page.Background.VersionMostRecent'
// and
// p2.Property_Name = 'Page.Background.VersionLastApproved'
filter.Add(
new PredicateExpression(
Predicatefactory.CompareValue(
PropertyValuesForPageFieldIndex.PropertyName, ComparisonOperator.Equal,
"Page.Background.VersionMostRecent", "p1"),
Predicatefactory.CompareValue(
PropertyValuesForPageFieldIndex.PropertyName, ComparisonOperator.Equal,
"Page.Background.VersionMostRecent", "p2")));
// Add:
// p1.PropertyValue != p2.PropertyValue
IEntityField p2PropertyValue = EntityFieldFactory.Create(PropertyValuesForPageFieldIndex.PropertyValue);
p2PropertyValue.ObjectAlias = "p2";
filter.Add(PredicateFactory.CompareExpression(
PropertyValuesForPageFieldIndex.PropertyValue, ComparisonOperator.NotEqual,
new Expression(p2PropertyValue)));
// fetch the dynamic list.
DataTable dynamicList = new DataTable();
TypedListDAO dao = new TypedListDAO();
dao.GetMultiAsDataTable(fields, dynamicList, 0, null, filter, relations, false, null, null, 0, 0);
// you can also use the relation and predicate to fetch entities:
PageCollection pages = new PageCollection();
pages.GetMulti(filter, relations);
To speed up the joins, you can move some predicates to the relation's as a CustomFilter, which you can specify as a property like:
relations.Add(...).CustomFilter = ...;