In SQL this brings back all the rows which have a matching record in both tables.
SELECT *
FROM table1
INNER JOIN table2 ON table2.t2ID = table1.t1ID
WHERE ANumberField = '2'`
I've got a QueryExpression that returns this.
QueryExpression theQuery = new QueryExpression("table1");
theQuery.ColumnSet.AddColumns("t1ID ");
LinkEntity link = theQuery.AddLink("table2", "t1ID ", "t2ID");
link.Columns.AddColumn("t2ID");
FilterExpression theFilter = link.LinkCriteria.AddFilter(LogicalOperator.Or);
theFilter.Conditions.Add(new ConditionExpression("ANumberField", ConditionOperator.Equal, 2));
Is there a way to invert that QueryExpression to do the equivalent of these?
This T-SQL gets records with a link, but not the criteria I need.
SELECT *
FROM table1
INNER JOIN table2 ON table2.t2ID = table1.t1ID
WHERE NOT ANumberField = '2'
This gets records with no link between the two tables.
SELECT *
FROM table1
WHERE t1ID NOT IN (SELECT t2ID FROM table2)
I tried what you wish to achieve, I used account and contact entity for my testing criteria is address1_line1 is not null. I got correct result as expeczed.