我訪問這樣的SharePoint列表:SharePoint列表=>數據表與標題名字
#region Accessing share point
Microsoft.SharePoint.Client.ClientContext cC = new Microsoft.SharePoint.Client.ClientContext(Link);
cC.Credentials = System.Net.CredentialCache.DefaultCredentials;
Microsoft.SharePoint.Client.List SPList = cC.Web.Lists.GetByTitle(ListName);
cC.Load(SPList.Fields);
Microsoft.SharePoint.Client.FieldCollection Fields = SPList.Fields;
#endregion
循環中的字段,我有所有不同領域的名稱信息。我是這樣做的:
int i = 0;
foreach(Microsoft.SharePoint.Client.Field FL in Fields)
{
WriteLine("Index: " + i++ + "; Internal name: " + FL.InternalName + "; Static name: " + FL.StaticName + "; Title: " + FL.Title);
}
出口是這樣的:
指數5;內部名稱:Lieferant_x0020__x0028_Nummer_x0;靜態名稱:Lieferant_x0020__x0028_Nummer_x0;標題:Lieferant(Nummer)
正如您所看到的,sharepoint通過使用unicode爲其他字符存儲內部名稱。只有在「FL.Title」中,名稱纔會存儲,因爲用戶可以在SharePoint列表中看到它。
現在,我想把這些數據放在一個DataTable中並對其進行過濾。我能做到這一點是這樣的:
Microsoft.SharePoint.Client.CamlQuery cQuery = new Microsoft.SharePoint.Client.CamlQuery();
cQuery = Microsoft.SharePoint.Client.CamlQuery.CreateAllItemsQuery();
Microsoft.SharePoint.Client.ListItemCollection LIC = SPList.GetItems(cQuery);
cC.Load(LIC);
cC.ExecuteQuery();
dt = new DataTable();
#region Create columns
foreach (var Field in LIC[0].FieldValues)
{
dt.Columns.Add(Field.Key);
}
#endregion
#region Reading data
foreach (Microsoft.SharePoint.Client.ListItem It in LIC)
{
System.Data.DataRow row = dt.NewRow();
foreach(var Field in It.FieldValues)
{
row[Field.Key] = Field.Value;
}
dt.Rows.Add(row);
}
#endregion
的問題是,在ListItemCollection,只能用其他字符爲Unicode的INTERNALNAME可用。我也無法編碼它,因爲SharePoint 2010只有32個字符的內部名稱導致剪輯名稱不再完整。
是否有任何可能性從0123列表中的列表中獲取標題ListItem.FieldValues
的KeyValuePair
?實際上,KeyValuePairs
都建立這樣的:
<br>
It.FieldValues.Key = //Column as Internal Name
It.FieldValues.Value = //Value
我需要:
It.FieldValues.Key = //Column as Title
It.FieldValues.Value = //Value
謝謝你在前進, 揚
不,這會導致錯誤。 (cQuery)之後不允許使用任何方法。 – CJens