コード例 #1
0
ファイル: Program.cs プロジェクト: CuneytKukrer/TestProject
        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);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: nickgoodrow/ODataSamples
        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();
        }