protected override void QueryChildObjects() // abstract { var childRetrievals = TermGroupDownloader.GetRetrievalsForMinimalProperties(); if (this.Options.GroupIdFilter != null) { // Load only groups appearing on the whitelist // "termGroup => termGroup.Id == guid1 || termGroup.Id == guid2 || termGroup.Id == guid3" Expression predicateBody = null; var termGroupParameter = Expression.Parameter(typeof(TermGroup), "termGroup"); foreach (var guid in this.Options.GroupIdFilter) { Expression comparison = Expression.Equal( Expression.Property(termGroupParameter, "Id"), Expression.Constant(guid) ); if (predicateBody == null) { predicateBody = comparison; } else { predicateBody = Expression.OrElse(predicateBody, comparison); } } var wherePredicate = Expression.Lambda <Func <TermGroup, bool> >( predicateBody, new ParameterExpression[] { termGroupParameter } ); // "termStore => termStore.Groups.Where(wherePredicate).Include(childRetrievals)" var termStoreParameter = Expression.Parameter(typeof(TermStore), "termStore"); var retrieval = Expression.Lambda <Func <TermStore, object> >( Expression.Call(typeof(ClientObjectQueryableExtension), "Include", new Type[] { typeof(TermGroup) }, new Expression[] { Expression.Call(typeof(Queryable), "Where", new Type[] { typeof(TermGroup) }, new Expression[] { Expression.Property(termStoreParameter, "Groups"), wherePredicate } ), Expression.Constant(childRetrievals) } ), new ParameterExpression[] { termStoreParameter } ); this.ClientContext.Load(this.ClientTermStore, retrieval); } else { // Load all groups this.ClientContext.Load(this.ClientTermStore, termStore => termStore.Groups.Include(childRetrievals)); } }
protected override void QueryMinimalProperties() { this.ClientContext.Load(this.ClientTermGroup, TermGroupDownloader.GetRetrievalsForMinimalProperties()); }