我是新來的SharePoint。我需要使用ClientContext
從SP列表中加載一些字段值。我使用Sharepoint客戶端對象模型。無法加載來自共享點列表的計算字段
這裏是我的代碼:
...
//Web spWeb
//CamlQuery camlQuery
List spList = spWeb.Lists.GetById(parameters.Config.List.ID);
ListItemCollection itemsCollection = spList.GetItems(camlQuery);
ClientContext.Load(itemsCollection, items => items.ListItemCollectionPosition);
ClientContext.Load(itemsCollection, items => items.Include(item => item.HasUniqueRoleAssignments, item => item.EffectiveBasePermissions, item => item.Id, item => item.FileSystemObjectType));
foreach (Dk14PhysicalField field in parameters.FieldsToReturn)//all required fields come here
{
ClientContext.Load(itemsCollection, items => items.Include(item => item[field.PhysicalName]));
}
try
{
ClientContext.ExecuteQuery();
}
catch (Exception ex)
{
//get exception here: Field or property "LinkTitle" does not exist.
}
哪裏CamlQuery XML是:
<View Scope="RecursiveAll">
<ViewFields>
<FieldRef Name="LinkTitle"/>
<FieldRef Name="Summary_x0020_Business_x0020_Des"/>
<FieldRef Name="City"/>
<FieldRef Name="Title"/>
<FieldRef Name="LinkTitleNoMenu"/>
<FieldRef Name="Modified"/>
<FieldRef Name="Author"/>
</ViewFields>
<RowLimit>2147483647</RowLimit>
<Query>
<OrderBy Override="TRUE">
<FieldRef Name="ID"/>
</OrderBy>
<Where>
<Or>...some conditions here...</Or>
</Where>
</Query>
</View>
此代碼工作正常,直到我嘗試加載計算領域LinkTitle
或LinkTitleNoMenu
在這種情況下,我得到的異常ExecuteQuery
:'Field or property "LinkTitle" does not exist.
'
理論上我可以得到這些計算的字段。要做到這一點,我不需要加載ListItemCollectionPosition
,只包含計算的字段到ClientContext
。如果我不執行這些技巧之一,執行將失敗,並出現不同的錯誤。
你有什麼想法嗎?