Sharepoint 2010 Managed Metadata - unable to get Term from TermSet
Having a really aggravating problem using Managed Metadata in SP2010 where I can get a Taxonomy Session, Term Store and Term set fine, but when I try to retrieve a term from the term set, I get a TermStoreOperationException which says that it "failed to read from or write to database".
Does anyone have any idea as to why I can get the Term Set but not the terms? I can't quite understand why when they all reside in the same database I can get the set but not the terms within it.
The code I'm using is below:
TaxonomySession txSession = new TaxonomySess开发者_如何转开发ion(site, true);
TermStore termStore = txSession.DefaultSiteCollectionTermStore;
TermSet termSet = termStore.GetTermSet(TermSetId);
TermCollection termCollection = termSet.GetTerms("My Term", true); //exception thrown on this line.
Any ideas or insight or solutions would be really appreciated.
Thanks heaps!
I managed to get around this by getting the Term just by using the indexer on the Term Set:
TermSet termSet = termStore.GetTermSet(txField.TermSetId);
Term myTerm = termSet.Terms["My Term"]);
I'm not sure why .GetTerms() doesn't work - it might be because SP2010 is still not RTM and it's meant to be an internal method, or some other mysterious reason beyond my comprehension...
精彩评论