[英]Query that get the projects whose name 'starts with'. Project Server 2013
Attempt to obtain projects that begin with a particular word , but I get the following error: "The 'StartsWith' member cannot be used in the expression." 尝试获取以特定单词开头的项目,但出现以下错误:“表达式中不能使用'StartsWith'成员。”
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();
I'm not too familiar with special queries like that. 我对这样的特殊查询不太熟悉。 But a quick workaround would probably be to get the whole collection and iterate it afterwards.
但是,一种快速的解决方法可能是获取整个集合,然后对其进行迭代。 Hopefully you do not have a million projects in your PWA :)
希望您的PWA中没有一百万个项目:)
projContext.Load(projContext.Projects);
projContext.ExecuteQuery();
foreach (PublishedProject pubProj in projContext.Projects)
{
if (pubProj.Name.StartsWith("yourString") {
// Do something
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.