Skip to content

Instantly share code, notes, and snippets.

@mikeedwards83
Created March 18, 2013 23:30
Show Gist options
  • Select an option

  • Save mikeedwards83/5191976 to your computer and use it in GitHub Desktop.

Select an option

Save mikeedwards83/5191976 to your computer and use it in GitHub Desktop.
var currentItem = context.GetCurrentItem<Parent>();
var newChild = new Child();
//we use the Name property as the item name when creating an item
newChild.Name = "MyNewChild";
//you can map other properties here
newChild.PageTitle ="My New Child";
using(new SecurityDisabler()){
context.Create(parent, child);
}
[SitecoreClass]
public class Parent
{
[SitecoreId]
public virtual Guid Id{get;set;}
}
[SitecoreClass]
public class Child
{
[SitecoreId]
public virtual Guid Id{get;set;}
[SitecoreInfo(SitecoreInfoType.Name)]
public virtual string Name{get;set;}
[SitecoreField]
public virtual string PageTitle{get;set;}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment