Is this really the version you are looking for? Kentico Xperience 12 Service Pack API is no longer updated. Use the switcher in the header to choose your product version.
List of examples:
// Creates a new relationship name object
RelationshipNameInfo newName = new RelationshipNameInfo();
// Sets the relationship name properties
newName.RelationshipDisplayName = "New relationship";
newName.RelationshipName = "NewRelationship";
// Saves the relationship name to the database
RelationshipNameInfoProvider.SetRelationshipNameInfo(newName);// Gets the relationship name
RelationshipNameInfo updateName = RelationshipNameInfoProvider.GetRelationshipNameInfo("NewRelationship");
if (updateName != null)
{
// Updates the relationship name properties
updateName.RelationshipDisplayName = updateName.RelationshipDisplayName.ToLower();
// Saves the updated relationship name to the database
RelationshipNameInfoProvider.SetRelationshipNameInfo(updateName);
}// Gets all relationship names whose code name starts with 'New'
var relationshipNames = RelationshipNameInfoProvider.GetRelationshipNames().WhereStartsWith("RelationshipName", "New");
// Loops through individual relationship names
foreach (RelationshipNameInfo name in relationshipNames)
{
// Updates the relationship name properties
name.RelationshipDisplayName = name.RelationshipDisplayName.ToUpper();
// Saves the updated relationship name to the database
RelationshipNameInfoProvider.SetRelationshipNameInfo(name);
}// Gets the relationship name
RelationshipNameInfo relationshipName = RelationshipNameInfoProvider.GetRelationshipNameInfo("NewRelationship");
if (relationshipName != null)
{
// Allows the relationship name to be used on the current site
RelationshipNameSiteInfoProvider.AddRelationshipNameToSite(relationshipName.RelationshipNameId, SiteContext.CurrentSiteID);
}// Gets the relationship name
RelationshipNameInfo relationshipName = RelationshipNameInfoProvider.GetRelationshipNameInfo("NewRelationship");
if (relationshipName != null)
{
// Gets the relationship between the relationship name and the current site
RelationshipNameSiteInfo nameSite =
RelationshipNameSiteInfoProvider.GetRelationshipNameSiteInfo(relationshipName.RelationshipNameId, SiteContext.CurrentSiteID);
// Removes the relationship name from the site
RelationshipNameSiteInfoProvider.DeleteRelationshipNameSiteInfo(nameSite);
}// Gets the relationship name
RelationshipNameInfo deleteName = RelationshipNameInfoProvider.GetRelationshipNameInfo("NewRelationship");
if (deleteName != null)
{
// Deletes the relationship name
RelationshipNameInfoProvider.DeleteRelationshipName(deleteName);
}// Gets the relationship name
RelationshipNameInfo relationshipName = RelationshipNameInfoProvider.GetRelationshipNameInfo("NewRelationship");
if (relationshipName != null)
{
// Prepares a TreeProvider instance
TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
// Gets the pages that will be connected through the relationship
TreeNode firstPage = tree.SelectNodes()
.Path("/FirstPage")
.OnCurrentSite()
.Culture("en-us")
.TopN(1)
.FirstOrDefault();
TreeNode secondPage = tree.SelectNodes()
.Path("/SecondPage")
.OnCurrentSite()
.Culture("en-us")
.TopN(1)
.FirstOrDefault();
// Creates the relationship between the pages
RelationshipInfoProvider.AddRelationship(firstPage.NodeID, secondPage.NodeID, relationshipName.RelationshipNameId);
}// Gets the relationship name
RelationshipNameInfo relationshipName = RelationshipNameInfoProvider.GetRelationshipNameInfo("NewRelationship");
if (relationshipName != null)
{
// Prepares a TreeProvider instance
TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
// Gets the pages that are connected through the relationship
TreeNode firstPage = tree.SelectNodes()
.Path("/FirstPage")
.OnCurrentSite()
.Culture("en-us")
.TopN(1)
.FirstOrDefault();
TreeNode secondPage = tree.SelectNodes()
.Path("/SecondPage")
.OnCurrentSite()
.Culture("en-us")
.TopN(1)
.FirstOrDefault();
// Removes the relationship between the pages
RelationshipInfoProvider.RemoveRelationship(firstPage.NodeID, secondPage.NodeID, relationshipName.RelationshipNameId);
}