private ICollection <int> GetDeletedTermIDs() { if (deletedTerms == null) { deletedTerms = new List <int>(); SPList taxonomyHiddenList = SPExtensionHelper.GetTaxonomyHiddenList(manager.Site); TermStore termStore = manager.TermStore; SPQuery query = new SPQuery { Query = Caml.Equals("IdForTermStore", termStore.Id.ToString()).ToString(), ViewFields = Caml.ViewFields("IdForTerm").ToString() }; foreach (SPListItem item in taxonomyHiddenList.GetItems(query)) { if (termStore.GetTerm(new Guid((string)item["IdForTerm"])) == null) { deletedTerms.Add(item.ID); } } } return(deletedTerms); }
private CamlExpression HandleNullExpression(SPModelQueryFieldInfo field, bool negate) { CamlExpression expression = Caml.IsNull(field.FieldRef); if (field.FieldTypeAsString == "TaxonomyFieldType" || field.FieldTypeAsString == "TaxonomyFieldTypeMulti") { SPList taxonomyHiddenList = SPExtensionHelper.GetTaxonomyHiddenList(manager.Site); foreach (SPListItem item in taxonomyHiddenList.GetItems("IdForTerm")) { if (manager.TermStore.GetTerm(new Guid((string)item["IdForTerm"])) == null) { expression |= Caml.LookupIdEquals(field.FieldRef, item.ID); } } } if (negate) { return(~expression); } return(expression); }