I have a typed list with two fields, each from a different table. Here's my code to fill the list.
StoreIDAndNameTypedList stores = new StoreIDAndNameTypedList();
PredicateExpression filter = new PredicateExpression();
filter.Add(PredicateFactory.CompareValue(AccountFieldIndex.ParentAccountId, ComparisonOperator.Equal, storeOwner.AccountId));
filter.Add(PredicateFactory.CompareValue(AccountFieldIndex.CustomerTypeCode, ComparisonOperator.Equal, 5));
ISortExpression sorter = new SortExpression(SortClauseFactory.Create(AccountFieldIndex.AccountNumber, SortOperator.Ascending));
stores.Fill(0, sorter, true, filter);
That works fine. Now I realize due to Microsoft's poorly designed CRM database, I better check for null on one of the fields, AccountNumber, which is not a join field and indeed might be null. So I want only records where it is not null.
I tried this, but don't see the change in the SQL when I watch it come across in Profiler.
filter.Add(PredicateFactory.CompareNull(AccountFieldIndex.AccountNumber, true));
Second question, what exactly would be the difference between that line of code and this (which also doesn't work)
filter.Add(new FieldCompareNullPredicate(EntityFieldFactory.Create(AccountFieldIndex.AccountNumber), true));
(Late addition, I took out the flag to negate the predicate and I don't see any change the SQL. Boy I must be doing something obviously wrong here
)