In this article we will be seeing about the TermSet in SharePoint.

In this article we will be seeing the following:

Steps Involved:
Create a new TermSet for a group:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Taxonomy;
namespace EMM
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("http://serverName:10/"))
{
TaxonomySession taxonomySession = new TaxonomySession(site);
TermStore termStore = taxonomySession.TermStores["MMS"];
Group group = termStore.Groups["SharePoint Group"];
TermSet termSet = group.CreateTermSet("Word Automation Term Set");
termStore.CommitAll();
}
}
}
}

taxonomy.gif

Get all the termsets of a particular group:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Taxonomy;
namespace EMM
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("http://serverName:10/"))
{
TaxonomySession taxonomySession =
new TaxonomySession(site);
TermStore termStore = taxonomySession.TermStores[
"MMS"];
Group group = termStore.Groups[
"SharePoint Group"];
TermSetCollection termSetCol = group.TermSets;
foreach (TermSet termSet in termSetCol)
{
Console.WriteLine(termSet.Name);
}
Console.ReadLine();
}
}
}
}