Freigeben über


Project Server CSOM -Select few columns from a dataset

Below sample code is to select only name and ID for a resource using CSOM

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.ProjectServer.Client;
using Microsoft.SharePoint.Client;

namespace ReadResources
{
    class Program
    {
        private static ProjectContext projContext;
       
        private const string pwapath = "https://servername/pwa/";
        static void Main(string[] args)
        {
            var resinfo =new EnterpriseResourceCreationInformation();
            projContext = new ProjectContext(pwapath);
            projContext.Load(projContext.EnterpriseResources, nm => nm.Include(ls => ls.Name, ls => ls.Id));
            projContext.ExecuteQuery();
            foreach (EnterpriseResource  rs in projContext.EnterpriseResources)
            {
              Console.WriteLine("Resource name and ID" + rs.Name + rs.Id);
            }

            Console.ReadKey();  

        }
    }
}

 

Happy coding ......Cheers .. Ajith