2016-06-23 16 views
0

我可以創建ListItemCollection的列表嗎?我試圖改善從我的代碼加載時間,因爲我分別加載每個ListItemCollection。ListItemCollection的列表

ListItemCollection items; 

foreach (PublishedProject proj in projects) 
{ 
     items = list.GetItems(qry); 

     spClientCtx.Load(items); 
     spClientCtx.ExecuteQuery(); 
} 

我希望它是這樣的東西。

ListItemCollection items; 
List allItems; 

foreach (PublishedProject proj in projects) 
{ 
     items = list.GetItems(qry); 
     allItems.Add(items); 

} 
spClientCtx.Load(allItems); 
spClientCtx.ExecuteQuery(); 

這是可能或有沒有更好的方法來做到這一點,所以我只需要1「ExecuteQuery()」;

+0

哪裏是'內使用proj''foreach' –

+0

並不重要,我刪除大多數的代碼來簡化它 – socramm

回答

1

創建ListItemCollection的列表

List<ListItemCollection> l = new List<ListItemCollection>(); 
+0

現在感謝我明白這是如何工作 – socramm

+0

不客氣!也許將問題標記爲回答:D –

1

是啊是可以做到的,它應該像這樣工作

ListItemCollection items; 
List<ListItemCollection> allItems = new List<ListItemCollection>(); 

foreach (PublishedProject proj in projects) 
{ 

     items = list.GetItems(proj); 
     allItems.Add(items); 

} 
spClientCtx.Load(allItems); 
spClientCtx.ExecuteQuery(); 
+0

如果我這樣做,它不起作用,因爲'allItems'是一個數組,但如果我這樣做:'allItems [0]'。我得到豁免「請求使用太多的資源」。 – socramm