I recently upgraded my DevForce installation to v6.1.2.0 and after rebuilding my Model and attempting to compile my assemblies, I received two errors.
===============================================
IEntityQuery<Account> searchQuery = SourceRepository.AccountRepo.CreateSearch();
Collection<PredicateDescription> subSearch = new Collection<PredicateDescription>();
PredicateDescription accountSearch = PredicateBuilder.Make(typeof(Account), "DealerID", FilterOperator.IsEqualTo, FilterDealerRecord.ID);
CompositePredicateDescription compositeSubSearch = null;
if (!string.IsNullOrEmpty(SearchAccountName))
subSearch.Add(PredicateBuilder.Make(typeof(Account), "Name", FilterOperator.Contains, SearchAccountName));
if (!string.IsNullOrEmpty(SearchAccountNumber))
subSearch.Add(PredicateBuilder.Make(typeof(Account), "AccountNo", FilterOperator.Contains, SearchAccountNumber));
if (subSearch.Count > 0)
{
foreach (PredicateDescription pd in subSearch)
{
if (null != compositeSubSearch)
compositeSubSearch = compositeSubSearch.Or(pd);
else
ERROR ===> compositeSubSearch = new CompositePredicateDescription(pd.InstanceType, pd.PropertyName, pd.FilterOperator, pd.Value);
}
}
if (null != compositeSubSearch)
searchQuery = searchQuery.Where(accountSearch.And(compositeSubSearch));
else
searchQuery = searchQuery.Where(accountSearch);
SourceRepository.AccountRepo.SearchFor(searchQuery, null, pDefaultSuccess, pDefaultFailure, (pForceRefresh) ? LYNX.Infrastructure.CONSTANTS.QueryStrategies.QS_WithDataSourceAndCacheFetch_OverwriteChanges : LYNX.Infrastructure.CONSTANTS.QueryStrategies.QS_WithOptimizedFetch_PreserveChanges);
===============================================
I was previously using 6.0.7 and this code worked fine.
Basically I display a list of account on a grid. I provide a single "Search Field" with a couple of checkboxes that allows the user to tell the system to "Not include" certain fields in the search.
On this particular screen, I always have to include a filter for the "DealerID" so that I don't return accounts for any other dealer in the system. My query is simply WHERE DealerID == <ID> AND (Name.Contains(<searchCriteria>) OR AccountNo.Contains(<searchCriteria>)). This was my first implementation and it seemed to work just fine until I updated the DevForce libraries.
Error #1: On the PredicateDescription, the PropertyName is no longer exposed.
Error #2: I'm no longer able to construct an instance of the CompositePredicateDescription to use as a "starting point" to construct my OR criteria.
Maybe my original implementation wasn't the best approach, but can someone suggest a better approach or solution to the one I've listed above. I have my Repository methods currently designed to accept an IEntityQuery so I would like to continue to use this approach so that I don't have to refactor all of my repository classes and consumers.
Thanks,
George