0
我的要求是使用CSOM獲取文檔庫的子項數。計數應該只是直接的孩子數,並且不應該包括子孩數。我試圖使用下面的代碼來實現這一點:SharePoint Online:獲取文檔庫使用CSOM的兒童數量
var newObjClientContext = this.GetSharePointClientContext(accessToken, fullUri);
WebCollection collWeb = newObjClientContext.Web.GetSubwebsForCurrentUser(new SubwebQuery());
var documentLibrary = newObjClientContext.Web.Lists.GetById(docID);
ListItemCollection ltitems = null;
string vquery = @"<View >
<Query>
<Where>
<Or>
<Eq>
<FieldRef Name='FSObjType' />
<Value Type='Lookup'>1</Value>
</Eq>
<Eq>
<FieldRef Name='FSObjType' />
<Value Type='Lookup'>0</Value>
</Eq>
</Or>
</Where>
<OrderBy><FieldRef Name='FileLeafRef' Ascending='TRUE'></FieldRef></OrderBy>
</Query>
<RowLimit>" + recCount + @"</RowLimit>
</View>";
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = vquery;
ltitems = documentLibrary.GetItems(camlQuery);
newObjClientContext.Load(documentLibrary);
newObjClientContext.Load(ltitems, lists => lists.IncludeWithDefaultProperties(l => l.ParentList));
newObjClientContext.ExecuteQuery();
int totalcount = documentLibrary.ItemCount; //It includes count of all the items present at all levels.
任何人都可以建議我怎麼能讓兒童算在上述步驟?
你的意思是通過查詢選擇的項目數量? – tinamou
不,上述查詢選擇的項目將受限於指定的「RowLimit」。我想獲得該文檔庫的總孩子數。 – Saket
好吧,不可能。你想達到什麼目的?用分頁控制? – tinamou