Beispiel #1
0
        static void Main(string[] args)
        {
            var serviceUri = "http://192.168.70.118:8123/odata";
            var container = new Default.Container(new Uri(serviceUri));

            var product = new Product()
            {
                Name = "Yo-yo",
                Category = "Toys",
                Price = 4.95M
            };
            AddProduct(container, product);
            ListAllProducts(container);
            //var pr=container.Products.FirstOrDefault(p => p.Id == 1);
            //Console.WriteLine("{0} {1} {2}", pr.Name, pr.Price, pr.Category);
            Console.ReadKey(false);
        }
Beispiel #2
0
        private static void Post_ProductFamily_Products()
        {
            var container = new Container();
            Console.WriteLine("\n\t<< post productfamily.products >>");
            var key = 4;
            ProductFamily family = container.ProductFamilies.Where(pf => pf.Id == key).AsEnumerable().SingleOrDefault();

            var sql2012 = new Product
            {
                Name = "SQL Server 2012",
                ReleaseDate = new DateTime(2012, 3, 6),
                SupportedUntil = new DateTime(2017, 7, 11)
            };
            container.AddRelatedObject(family, "Products", sql2012);

            Console.WriteLine("\tCreating Product with Name={0} under ProductFamily with name {1}", sql2012.Name, family.Name);
            container.SaveChanges();
        }