Open Program.cs file and replace the code with the following
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Collections.ObjectModel;
using
Microsoft.SharePoint.Client;
using
Microsoft.SharePoint.Client.Taxonomy;
namespace
TaxonomyCodeSamples
{
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");
//
Returns the associated site collection group for the SPSite.
TermGroup
termGroup = termStore.GetSiteCollectionGroup(clientContext.Site,
false);
clientContext.Load(termGroup);
clientContext.ExecuteQuery();
//
Display the group name
Console.WriteLine(termGroup.Name);
Console.ReadLine();
}
}
}