Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

How to read Enterprise Resources based on Custom Field Value using CSOM

$
0
0

HI,

requirement to read resources based on custom field value at one shot using csom. i have written a code using nested where clause in linq on context.Load Statement.but it is giving error .plz help on this.

using (ProjectContext context = new ProjectContext(uri))
            {
                string cf = "Custom_38011a416ca5e51180eb00155d043716";
                string value = "value";
                context.Load(context.EnterpriseResources
                    );
                context.ExecuteQuery();
                //var q = from e in context.EnterpriseResources
                //        where e.FieldValues.Any(i=>i.Key==cf)
                //        //&& e.FieldValues.Any(f=>f.Value==value)
                //        select e;
                var r = context.EnterpriseResources.Where(i => i.FieldValues.Any(fs => fs.Key.Equals(cf)));


                foreach (EnterpriseResource er in context.EnterpriseResources)
                {
                    Console.WriteLine(er[cf].ToString());
                    Console.WriteLine(er.Name);
                }
            }



Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>