Esempio n. 1
0
        private void GetProduct()
        {
            Console.WriteLine("Get Product");
            Container c       = Container.New();
            var       product = c.Products.Where(p => p.ID == _lastIndex).Single();

            Console.WriteLine("\t{0} was found", product.Name);
        }
Esempio n. 2
0
        private void GetProductFamily()
        {
            Console.WriteLine("Get Product Family");
            Container c       = Container.New();
            var       product = c.Products.Where(p => p.ID == _lastIndex).Single();

            c.LoadProperty(product, "Family");
            Console.WriteLine("\t{0} was found", product.Family.Name);
        }
Esempio n. 3
0
        private void DeleteProduct()
        {
            Console.WriteLine("Delete Product");
            Container c       = Container.New();
            var       product = c.Products.Where(p => p.ID == _lastIndex).Single();

            c.DeleteObject(product);
            c.SaveChanges();
            Console.WriteLine("\t{0} was deleted", product.Name);
            GetProducts();
        }
Esempio n. 4
0
        private void QueryProducts()
        {
            Console.WriteLine("Get Products Since 2008/1/1");
            Container c      = Container.New();
            var       people = c.Products.Where(p => p.ReleaseDate > new DateTime(2008, 1, 1));

            foreach (var p in people)
            {
                Console.WriteLine("\t{0}: {1}", p.ID, p.Name);
            }
        }
Esempio n. 5
0
        private void PatchProduct()
        {
            Console.WriteLine("Patch Product");
            Container c       = Container.New();
            var       product = c.Products.Where(p => p.ID == _lastIndex).Single();

            product.ReleaseDate = new DateTime(2012, 10, 26);
            c.UpdateObject(product);
            c.SaveChanges();
            Console.WriteLine("\t{0}'s release date is changed to {1}", product.Name, product.ReleaseDate);
            GetProducts();
        }
Esempio n. 6
0
        private void LinkProductToFamily()
        {
            Console.WriteLine("Link Product to Family");
            Container c       = Container.New();
            var       product = c.Products.Where(p => p.ID == _lastIndex).Single();
            var       family  = c.ProductFamilies.Where(p => p.Name.Contains("Windows")).Single();

            c.SetLink(product, "Family", family);
            c.SaveChanges();

            Console.WriteLine("\t{0} was linked to {0} family", product.Name, family.Name);
            GetProducts();
        }
Esempio n. 7
0
        private void PostProduct()
        {
            Console.WriteLine("Post Product");
            Container c       = Container.New();
            Product   product = new Product {
                Name = "Windows 8"
            };

            c.AddToProducts(product);
            c.SaveChanges();
            Console.WriteLine("\t{0} was added", product.Name);
            GetProducts();
        }
Esempio n. 8
0
        private void GetProducts()
        {
            Console.WriteLine("Get Products");
            Container c      = Container.New();
            var       people = c.Products.ToList();

            foreach (var p in people)
            {
                Console.WriteLine("\t{0}: {1}", p.ID, p.Name);
            }

            _lastIndex = people.Select(p => p.ID).Max();
        }