Exemplo n.º 1
0
        private static async Task CreateGameFigures(CharacterContext context)
        {
            var mario = CreateCharacter("Mario", Origin.MushroomKingdom);
            var yoshi = CreateCharacter("Yoshi", Origin.MushroomKingdom);
            var link  = CreateCharacter("Link", Origin.Hyrule);
            await context.AddRangeAsync(mario, yoshi, link);

            await context.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public static async Task Main(string[] args)
        {
            var options = new DbContextOptionsBuilder <CharacterContext>()
                          .UseInMemoryDatabase("sample")
                          .Options;

            await using var context = new CharacterContext(options);
            await CreateGameFigures(context);

            var characters = await context.Characters.ToListAsync();

            characters.ForEach(c =>
            {
                Console.WriteLine($"{c.Name} comes from {c.Origin.DisplayName} (Ruler: {c.Origin.Ruler})");
            });
        }