В моем удаленном приемнике событий SharePoint есть следующий код: -
//create empty TaxonomyFieldValueCollection
var field = templatelsit.Fields.GetByInternalNameOrTitle("Fund");
var taxField = context.CastTo<TaxonomyField>(field);
currentFilingSystemItem["Fund"] = new TaxonomyFieldValueCollection(context, null, taxField);
//code goes here...
//check if the Fund is empty
var taxValue2 = currentFilingSystemItem["Fund"] as TaxonomyFieldValueCollection;
if(taxValue2.Count > 0)
{
var taxonomyFieldValueArray2 = taxValue2.Select(taxonomyFieldValue => $"{taxonomyFieldValue.Label}|{taxonomyFieldValue.TermGuid}");
listItem["Fund"] = String.Join(";", taxonomyFieldValueArray2);
}
, но при taxValue2.Count > 0
я получу эту ошибку The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
Может кто-нибудь посоветовать по этому поводу?
Я пытался использовать
context.load(taxValue2);
context.ExecuteQuery();
if(taxValue2.Count > 0)
, но я получил эту ошибку The object is not associated with an object identity or the object identity is invalid.