Ejemplo n.º 1
0
        private static void Put_ProductFamily()
        {
            Container ctx = new Container();

            Console.WriteLine("\t<< put productfamily >>");
            ProductFamily family = ctx.ProductFamilies.Where(pf => pf.ID == 4).FirstOrDefault();

            if (family != null)
            {
                family.Description = "Updated Description";
                ctx.UpdateObject(family);

                ctx.SaveChanges(SaveChangesOptions.ReplaceOnUpdate);
            }
        }
Ejemplo n.º 2
0
        private static void Delete_ProductFamily()
        {
            Container ctx = new Container();

            Console.WriteLine("\t<< delete productfamily >>");
            //NOTE: WE ARE DOING A GET HERE
            ProductFamily family = ctx.ProductFamilies.Where(pf => pf.ID == 4).FirstOrDefault();

            if (family != null)
            {
                //DELETE HERE
                ctx.DeleteObject(family);
                ctx.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        private static void Patch_ProductFamily()
        {
            Container ctx = new Container();

            Console.WriteLine("\t<< patch productfamily >>");
            ProductFamily family = ctx.ProductFamilies.Where(pf => pf.ID == 4).AsEnumerable().SingleOrDefault();

            if (family != null)
            {
                family.Description = "Patched Description";
                ctx.UpdateObject(family);

                ctx.SaveChanges(SaveChangesOptions.PatchOnUpdate);
            }
        }
Ejemplo n.º 4
0
        private static void Post_ProductFamily()
        {
            Container ctx = new Container();

            Console.WriteLine("\t<< post productfamily >>");
            ProductFamily sql = new ProductFamily
            {
                ID          = 4,
                Name        = "SQL SERVER",
                Description = "A relational database engine."
            };

            ctx.AddObject("ProductFamilies", sql);
            ctx.SaveChanges();
        }
Ejemplo n.º 5
0
        private static void Post_ProductFamily()
        {
            var container = new Container();

            Console.WriteLine("\n\t<< post productfamily >>");
            var newData = new ProductFamily
            {
                Id          = 4,
                Name        = "SQL SERVER",
                Description = "A relational database engine."
            };

            Console.WriteLine("\tCreating ProductFamily with Id={0}, Name={1}, Description={2}", newData.Id, newData.Name, newData.Description);

            container.AddObject("ProductFamilies", newData);
            container.SaveChanges();
        }
Ejemplo n.º 6
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();
        }
Ejemplo n.º 7
0
        private static void Delete_ProductFamily()
        {
            var container = new Container();

            Console.WriteLine("\n\t<< delete productfamily >>");
            var           key    = 4;
            ProductFamily family = container.ProductFamilies.Where(pf => pf.Id == key).FirstOrDefault();

            if (family != null)
            {
                Console.WriteLine("\tDeleting ProductFamily with Id={0}, Name={1}", family.Id, family.Name);

                container.DeleteObject(family);
                container.SaveChanges();
            }
            else
            {
                Console.WriteLine("\tProductFamily with Id '{0}' not found.", key);
            }
        }
Ejemplo n.º 8
0
        private static void Put_ProductFamily()
        {
            Container ctx = new Container();

            Console.WriteLine("\n\t<< put productfamily >>");
            int           key    = 4;
            ProductFamily family = ctx.ProductFamilies.Where(pf => pf.ID == key).FirstOrDefault();

            if (family != null)
            {
                Console.WriteLine("\tUpdating ProductFamily with Id={0}, Name={1}", family.ID, family.Name);

                family.Description = "Updated Description";
                ctx.UpdateObject(family);

                ctx.SaveChanges(SaveChangesOptions.ReplaceOnUpdate);
            }
            else
            {
                Console.WriteLine("\tProductFamily with Id '{0}' not found.", key);
            }
        }
Ejemplo n.º 9
0
        private static void Patch_ProductFamily()
        {
            Container ctx = new Container();

            Console.WriteLine("\n\t<< patch productfamily >>");
            int           key    = 4;
            ProductFamily family = ctx.ProductFamilies.Where(pf => pf.ID == key).AsEnumerable().SingleOrDefault();

            if (family != null)
            {
                Console.WriteLine("\tPatching ProductFamily with Id={0}, Name={1}", family.ID, family.Name);

                family.Description = "Patched Description";
                ctx.UpdateObject(family);

                ctx.SaveChanges(SaveChangesOptions.PatchOnUpdate);
            }
            else
            {
                Console.WriteLine("\tProductFamily with Id '{0}' not found.", key);
            }
        }
Ejemplo n.º 10
0
        private static void Post_ProductFamily()
        {
            var container = new Container();

            Console.WriteLine("\n\t<< post productfamily >>");
            var newData = new ProductFamily
            {
                Id = 4,
                Name = "SQL SERVER",
                Description = "A relational database engine."
            };

            Console.WriteLine("\tCreating ProductFamily with Id={0}, Name={1}, Description={2}", newData.Id, newData.Name, newData.Description);

            container.AddObject("ProductFamilies", newData);
            container.SaveChanges();
        }