简体   繁体   中英

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."

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 :)

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM