API support

CSOM SSOM

Can be deployed under

Web

Notes

List and library provision is enabled via ListDefinition object.

Both CSOM/SSOM object models are supported. Provision checks if list exists looking up it by Url property, then creates a new list. You can deploy either single list or a set of the lists using AddList() extension method as per following examples.

Examples

Add list by template type

var genericList = new ListDefinition
{
    Title = "Generic list",
    Description = "A generic list.",
    TemplateType = BuiltInListTemplateTypeId.GenericList,
    Url = "GenericList"
};

var documentLibrary = new ListDefinition
{
    Title = "Document library",
    Description = "A document library.",
    TemplateType = BuiltInListTemplateTypeId.DocumentLibrary,
    Url = "DocumentLibrary"
};

var model = SPMeta2Model.NewWebModel(web =>
{
    web.AddList(genericList);
    web.AddList(documentLibrary);
});

DeployModel(model);


                            
Add list by template name

var contactsList = new ListDefinition
{
    Title = "Some Assert",
    Description = "Some Assert.",
    TemplateName = BuiltInListTemplates.AssetLibrary.InternalName,
    Url = "SomeAssert"
};

var model = SPMeta2Model.NewWebModel(web =>
{
    web.AddList(contactsList);
});

DeployModel(model);


                            
Add host Style Library

var model = SPMeta2Model.NewWebModel(web =>
{
    web.AddHostList(BuiltInListDefinitions.StyleLibrary, list =>
    {
        // do stuff
    });
});

DeployModel(model);


                            
Add host OOTB lists

var model = SPMeta2Model.NewWebModel(web =>
{
    web.AddHostList(BuiltInListDefinitions.StyleLibrary, list =>
    {
        // do stuff
    });

    web.AddHostList(BuiltInListDefinitions.Catalogs.MasterPage, list =>
    {
        // do stuff
    });

    web.AddHostList(BuiltInListDefinitions.SitePages, list =>
    {
        // do stuff
    });

    web.AddHostList(BuiltInListDefinitions.SiteAssets, list =>
    {
        // do stuff
    });
});

DeployModel(model);


                            
Add multiple lists

var model = SPMeta2Model.NewWebModel(web =>
{
    web
        .AddWeb(DocWebs.AboutOurCompany, aboutWeb =>
        {
            aboutWeb
                .AddList(DocLists.AboutUsLists.ManagementTeam)
                .AddList(DocLists.AboutUsLists.OurClients);
        })
        .AddWeb(DocWebs.DepartmentWebs.HR, hrWeb =>
        {
            hrWeb
                .AddList(DocLists.HRLists.AnnualReviews)
                .AddList(DocLists.HRLists.Poicies)
                .AddList(DocLists.HRLists.Procedures);
        })
        .AddWeb(DocWebs.Departments, departmentWeb =>
        {
            departmentWeb
                .AddList(DocLists.DepartmentsLists.IssueRegister)
                .AddList(DocLists.DepartmentsLists.TeamEvents)
                .AddList(DocLists.DepartmentsLists.TeamTasks);
        });
});

DeployModel(model);


                            
Add promoted links list

var listDef = new ListDefinition
{
    Title = "My Links",
    TemplateName = BuiltInListTemplates.PromotedLinks.InternalName,
    CustomUrl = "/lists/my-links"
};

var model = SPMeta2Model.NewWebModel(web =>
{
    web.AddList(listDef);
});

DeployModel(model);