0

I'm attempting to Create a Document Library from a custom list template using CSOM. Using answers from similar question, I ran the following code but I'm receiving build error CS0200 Property or indexer 'ListTemplate.Name' cannot be assigned to -- it is read only.

using (ClientContext ctx = new ClientContext(siteUrl))
{
    Web site = ctx.Web;
    ctx.Load(site, s => s.ListTemplates);
    ctx.ExecuteQuery();

    //create a list
    ListCreationInformation info = new ListCreationInformation
    {
        Title = clientId,
        Description = "Client Library",
    };

    ListTemplate listTemplate = site.ListTemplates.First(lt => lt.Name = "ClientID");
    info.TemplateFeatureId = listTemplate.FeatureId;
    info.TemplateType = listTemplate.ListTemplateTypeKind;

    site.Lists.Add(info);
    ctx.ExecuteQuery();
}

1 Answer 1

3

This row

ListTemplate listTemplate = site.ListTemplates.First(lt => lt.Name = "ClientID");

should be

ListTemplate listTemplate = site.ListTemplates.First(lt => lt.Name.Equals("ClientID"));

You need to compare the values, not assign one to the other.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.