var collection1 = new EntityCollection<OrderEntity>();
var bucket2 = new RelationPredicateBucket();
bucket2.PredicateExpression.Add(new FieldCompareSetPredicate(null, null, AccountReminderFields.AccountReminderId, null, SetOperator.Exist, null, true));
var adapter2 = new DataAccessAdapter();
adapter2.FetchEntityCollection(collection1, bucket2);
This simple code with entities not from an inheritance hierarchy results in the following sub-squery...
WHERE ( ( NOT EXISTS (SELECT [bangfaceweekender ].[dbo].[tbl_account_reminder].[AccountReminderID] AS [AccountReminderId] FROM [bangfaceweekender ].[dbo].[tbl_account_reminder] ))
I presume that the sub-query is using 'tbl_account_reminder' in its from clause because an AccountReminderEntity field is specified in the FieldCompareSetPredicate predicate constructor call.
But I'm creating the FieldCompareSetPredicate in a similar way in the original query and yet there 'tbl_account_reminder' is missing from the from clause. Surely it should still be there?
The problem is that you're using inheritance, and it has to join the subtype tables as you're referring to these tables through the fields in the filter specified in the fieldcompareset predicate.
I'm not quite following. I don't see why the sub-query should need to refer to these tables in the from clause at all.
The sub-query should just look like this when the filter is added to the FieldCompareSetPredicate predicate constructor call...
WHERE ( ( NOT EXISTS (SELECT [bangfaceweekender ].[dbo].[tbl_account_reminder].[AccountReminderID] AS [AccountReminderId]
FROM [bangfaceweekender ].[dbo].[tbl_account_reminder]
WHERE [bangfaceweekender ].[dbo].[tbl_account_reminder].[AccountReminderTypeID] = @AccountReminderTypeId1
AND [bangfaceweekender ].[dbo].[tbl_account_reminder].[AccountID] = [bangfaceweekender ].[dbo].[vw_chalet_account].[AccountID]))
...and '[bangfaceweekender ].[dbo].[vw_chalet_account]' refers to the sub-query's parent query.
I'm trying to write a correlated sub-query here right?!