Ejemplo n.º 1
0
        private static void ViewData5()
        {
            using (var ctx = new EFRecipesEntities5())
            {
                var all   = ctx.PictureCategories.ToList();
                var roots = all.Where(x => x.ParentCategory == null).ToList();
                // var rootBoost = ctx.PictureCategories.AsNoTracking().ToList();
                roots.ForEach(root => Print(root, 0));

                var entry = ctx.Entry(all.FirstOrDefault());
                var cv    = entry.CurrentValues["Name"];
            }
        }
Ejemplo n.º 2
0
        private static void AddData5()
        {
            using (var ctx = new EFRecipesEntities5())
            {
                var louvre = new PictureCategory {
                    Name = "Louvre"
                };
                var child = new PictureCategory {
                    Name = "Egyptian Antiquites"
                };
                louvre.Subcategories.Add(child);
                child = new PictureCategory {
                    Name = "Sculptures"
                };
                louvre.Subcategories.Add(child);
                child = new PictureCategory {
                    Name = "Paintings"
                };
                louvre.Subcategories.Add(child);
                var paris = new PictureCategory {
                    Name = "Paris"
                };
                paris.Subcategories.Add(louvre);
                var vacation = new PictureCategory {
                    Name = "Summer Vacation"
                };
                vacation.Subcategories.Add(paris);
                ctx.PictureCategories.Add(paris);
                ctx.SaveChanges();

                /*
                 * PictureCategory pc1 = new PictureCategory() { Name = "L1a" };
                 * PictureCategory pc2 = new PictureCategory() { Name = "L1b" };
                 * PictureCategory pc3 = new PictureCategory() { Name = "L1c" };
                 * PictureCategory pc4 = new PictureCategory() { Name = "L1d" };
                 * pc4.Subcategories.Add(new PictureCategory { Name = "L2a" });
                 * pc4.Subcategories.Add(new PictureCategory { Name = "L2b" });
                 * PictureCategory pc = new PictureCategory() { Name = "L" };// Subcategories = new List<PictureCategory> { pc1, pc2, pc3, pc4 } };
                 * pc.Subcategories.Add(pc1);
                 * pc.Subcategories.Add(pc2);
                 * pc.Subcategories.Add(pc3);
                 * ctx.PictureCategories.Add(pc);
                 * ctx.SaveChanges();*/
            }
        }