0

嘗試獲取以特定單詞開頭的項目,但出現以下錯誤:「'StartsWith'成員不能用於表達式中。」獲取名稱'開始'的項目的查詢。 Project Server 2013

ProjectContext projContext = new ProjectContext(urlPWA); 
projContext.Credentials = new SharePointOnlineCredentials(user,passwordSecurity); 

projContext.Load(projContext.Projects, c => c.Where(p => p.Name.StartsWith(name, true, new CultureInfo("es-ES"))).IncludeWithDefaultProperties(f => f.Name, f => f.Tasks, f => f.ProjectResources, f => f.Owner.UserId, f => f.CheckedOutBy.UserId)); 

projContext.ExecuteQuery(); 

回答

0

我不太熟悉這樣的特殊查詢。但是一個快速的解決方法可能是獲取整個集合並在之後進行迭代。希望你在PWA中沒有一百萬個項目:)

projContext.Load(projContext.Projects); 
projContext.ExecuteQuery(); 

foreach (PublishedProject pubProj in projContext.Projects) 
{ 
    if (pubProj.Name.StartsWith("yourString") { 
    // Do something 
    } 
}