2012-11-08 70 views
1

我得到此錯誤@列表)itemPage.userId無法投射類型爲'Linq.LookupList`1 [System.Nullable`1 [System.Int32]]'的對象以鍵入Generic.List`1 [System.Nullable`1 [System.Int32]]'

無法轉換類型的對象 'Microsoft.SharePoint.Linq.LookupList 1[System.Nullable 1 [System.Int32]]' 爲類型「System.Collections.Generic.List 1[System.Nullable 1 [系統。 INT32]」

代碼:

List<MySitePage> userId = PagesFacade.GetPages(web.Url, (List<int?>)itemPage.userId); 

其中userid在ItemPage是私人Microsoft.SharePoint.Linq.LookupList<System.Nullable<int>> _userId ;

public static List<MySitePage> GetPages(string relativeWebUrl, List<int?> userIds) 

回答

1

LookupList<T> implements IList<T>,not List。下面是具體實現:

public sealed class LookupList<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, ICloneable 

既然如此,因爲它是IEnumerable的,你可以嘗試調用集合ToList,並希望它實現它(雖然我還沒有實際使用的共享點的集合)。所以試試這個:

List<MySitePage> userId = PagesFacade.GetPages(web.Url, itemPage.userId.ToList()); 
+0

謝謝SPFiredrake IList 爲我工作。 –

相關問題