Sharepoint client object model: How to get all the fields in a list

后端 未结 2 2007
感情败类
感情败类 2021-02-04 20:49

I have a list named \"Discussions List\". I want to bring all columns from the list.

I want to know how to do it SharePoint Client Object Model.

2条回答
  •  误落风尘
    2021-02-04 21:23

    OK. Found the solution. Answer Here using a list I'm getting by title, but will work with any method:

    // Get your ClientContext for your site  in 'clientContext'
    
    SP.List oList = clientContext.Web.Lists.GetByTitle("List Title Here"); 
    SP.FieldCollection fieldColl = oList.Fields;
    clientContext.Load(fieldColl);
    clientContext.ExecuteQuery();
    
    foreach (SP.Field fieldTemp in fieldColl)
    {
        MessageBox.Show(fieldTemp.InternalName.ToString()); //I used MessageBox to show, but you can do whatever you like with it here.
    }
    

提交回复
热议问题