using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Taxonomy;
using System.Collections.ObjectModel;
namespace ManagedMetadataClient
{
class Program
{
static void Main(string[] args)
{
// ClienContext - Get the context for the SharePoint Site
// SharePoint site URL - http://c4968397007/
ClientContext clientContext = new ClientContext("http://c4968397007/");
// Get the TaxonomySession
TaxonomySession taxonomySession = TaxonomySession.GetTaxonomySession(clientContext);
// Get the term store by Name
TermStore termStore = taxonomySession.TermStores.GetByName("MMS");
// Get the term group by Name
TermGroup termGroup = termStore.Groups.GetByName("SP2013");
// Get the term set by Name
TermSet termSet = termGroup.TermSets.GetByName("BCS");
// Get the term by Name
Term term = termSet.Terms.GetByName("External Content Type");
// Get all the labels for the term
LabelCollection labelColl = term.Labels;
clientContext.Load(labelColl);
// Execute the query to the server
clientContext.ExecuteQuery();
// Loop through all the labels
foreach (Label label in labelColl)
{
// Display the label value
Console.WriteLine(label.Value);
}
}
}
}