Exemplo n.º 1
0
        private static void ExplicitLoadFootballers()
        {
            var club = _context.Clubs.FirstOrDefault(c => c.ClubName.Contains("L"));

            _context.Entry(club).Collection(c => c.Footballers).Load();
            _context.Entry(club).Reference(c => c.Coach).Load();
        }
Exemplo n.º 2
0
        public void CanInsertClubIntoDatabase()
        {
            var builder = new DbContextOptionsBuilder();

            builder.UseInMemoryDatabase("CanInsertClub");
            using (var context = new FootballManagerContext(builder.Options))
            {
                var club = new Club();
                context.Clubs.Add(club);
                Assert.AreEqual(EntityState.Added, context.Entry(club).State);
            }
        }