我访问这样的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