Esempio n. 1
0
        public System.Collections.IList GetObjects(string entityName, CriteriaOperator filter, Dictionary <string, string> properties)
        {
            DataServiceQuery query = CreateObjectQuery(entityName, filter, properties);
            var result             = query.ToList();

            return(result);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Uri uri = new Uri("http://localhost:8083/ExamDataService");
            ExamCodeFirstContext ctx = new ExamCodeFirstContext(uri);

            bool tryAgain = true;

            do
            {
                IEnumerable <Customer> customers = ctx.Customers.ToList();
                Console.WriteLine(string.Format("Retrieved {0} customers from the WCF Data Service", customers.Count()));

                // Try replacing Id with id and see how WCF throws an excellent exception!
                DataServiceQuery <Customer> customerQuery = ctx.Customers.AddQueryOption("$filter", "Id gt 1");
                customers = customerQuery.ToList();

                Console.WriteLine(string.Format("Retrieved {0} customers from the WCF Data Service using DataServiceQuery", customers.Count()));


                Console.WriteLine("Re-run? (Y/N)");
                if (Console.ReadLine() != "Y")
                {
                    tryAgain = false;
                }
            }while (tryAgain);

            Console.WriteLine("Press <Enter> to stop the client.");
            Console.ReadLine();
        }
Esempio n. 3
0
        public static DictionaryTree <Group, Y> ToDictionaryTree <Y>(this DataServiceQuery <Group> groupsDb, Func <Group, Y> getKey, Guid rootGroupId) where Y : class
        {
            var groups       = groupsDb.ToList();
            var childsGroups = groups.Where(g => g.ParentId == rootGroupId).ToList();
            var root         = new DictionaryTree <Group, Y>(getKey, null);

            groups.CastListToDictionaryTree(root, childsGroups);
            return(root);
        }