private static DbContext InitializeDatabase()
        {
            var context = new WebAuctionDbContext(Effort.DbConnectionFactory.CreatePersistent(TestDbConnectionString));

            var electro = new Category
            {
                Id          = Guid.Parse("00000001-a1de-42ca-ae58-0083fa9f0d7f"),
                Name        = "Electronics",
                Description = "Smartphones, laptops and other electronic devices.",
                ParentId    = null,
                Parent      = null
            };

            var smartphones = new Category
            {
                Id          = Guid.Parse("00000011-a1de-42ca-ae58-0083fa9f0d7f"),
                Name        = "Smartphones",
                Description = "Smartphone category",
                ParentId    = electro.Id,
                Parent      = electro
            };

            context.Categories.AddOrUpdate(category => category.Id, electro, smartphones);

            return(context);
        }
Exemplo n.º 2
0
 public static void Main()
 {
     Console.WriteLine("Categories: ");
     using (var db = new WebAuctionDbContext())
     {
         foreach (var category in db.Categories)
         {
             Console.Write($"{category.Id} - {category.Name} - ");
             Console.WriteLine("[" + category.Description + "]");
         }
     }
 }