I'm trying to get some content by taxonomies, that are a part of that content/ Here's what I have:
var taxonomyTerms = _taxonomyService.GetTerms(taxonomy.Id).Where(t => termsToSearch.Contains(t.Name)).ToList();
var listOfTermsIds= taxonomyTerms.Select(x => x.Id).ToList();
//works well until here, I have my list of terms ids
var originalContentItems = _cm
.Query<GenericContentPart, GenericContentRecord>()
.Join<TermsPartRecord>().Where(l => !l.Terms.Select(t => t.TermRecord.Id).Except(listOfTermsIds).Any()).List();
//this returns no records
I've managed to do this with a foreach, but I want to do the same with an expression. The problem is that last bit of code doesn't return me any records.
Any help?
I found the problem:
contentItems = _cm
.Query<GenericContentPart, GenericContentRecord>()
.Join<TermsPartRecord>().ForPart<TermsPart>().List()
.Where(l => !listOfTermsIds.Except(l.Terms.Select(t => t.TermRecord.Id).ToList()).Any());
Thanks.