I'm doing something silly, but can't figure it out.
I would like a list of all the Charities(parent) and their contributions(children) between a date, but I always want all the Charities regardless if they have a contributions. ObeyWeakRelations is the answer?
I am getting **only **those Charities with contributions in the date range. I need all Charities always.
//My charity collection
CharityOrganizationCollection charityCol = new CharityOrganizationCollection();
//Prefetch the contributions
PrefetchPath prefetch = new PrefetchPath((int)EntityType.CharityOrganizationEntity);
prefetch.Add(CharityOrganizationEntity.PrefetchPathContributions);
//Sort by Name
ISortExpression sort = new SortExpression(new SortClause(CharityOrganizationFields.Name, SortOperator.Ascending));
//Add relations so we can filter on the date
RelationCollection relationsToUse = new RelationCollection();
relationsToUse.Add(CharityOrganizationEntity.Relations.ContributionEntityUsingCharityOrganizationFk);
relationsToUse.ObeyWeakRelations = true;
//Filter on the contribution date
IPredicateExpression select = new PredicateExpression();
select.Add(new FieldBetweenPredicate(ContributionFields.ContributionDate,FROM,TO));
//Get'm
charityCol.GetMulti(select, 0, sort,relationsToUse,prefetch);