public void ManyToMany()
        {
            using (var context = new SchoolContext(Options))
                using (var provider = new SelectPlusOneLoggerProvider(context, treshold: 2))
                {
                    // Arrange
                    var result = context
                                 .Person
                                 .Select(p => new
                    {
                        p.FirstName,
                        p.LastName,
                        Courses = p.StudentGrade.Select(sg => sg.Course.Title)
                    }).ToList();

                    // Act
                    Assert.NotEmpty(result);
                    foreach (var p in result)
                    {
                        foreach (var c in p.Courses)
                        {
                        }
                    }

                    // Assert
                    var ex = Assert.Throws <AggregateException>(() => provider.Verify());
                    Assert.IsType <PossibleSlectPlusOneQueryException>(ex.InnerException);
                }
        }
        public void IncludeNotIgnoredWhenProjectionAfterQueryExecution()
        {
            var options = Builder
                          .ConfigureWarnings(w => w.Throw(CoreEventId.IncludeIgnoredWarning))
                          .Options;

            using (var context = new SchoolContext(options))
                using (var provider = new SelectPlusOneLoggerProvider(context))
                {
                    var result = context
                                 .Person
                                 .Include(p => p.StudentGrade)
                                 .ThenInclude(pc => pc.Course)
                                 .ToList() // force execution, loading additional data, projecting later on
                                 .Select(p => new
                    {
                        p.FirstName,
                        p.LastName,
                        Courses = p.StudentGrade.Select(sg => sg.Course.Title)
                    }).ToList();

                    Assert.NotEmpty(result);
                    Assert.Contains(result, p => p.Courses.Any());

                    provider.Verify();
                }
        }
        public void OneToManyNavigationPropertyPartOfSelect()
        {
            using (var context = new SchoolContext(Options))
                using (var provider = new SelectPlusOneLoggerProvider(context, treshold: 2))
                {
                    var result = context
                                 .Person
                                 .Select(p => new
                    {
                        p.FirstName,
                        p.LastName,
                        Grades = p.StudentGrade
                    }).ToList();

                    Assert.NotEmpty(result);
                    foreach (var p in result)
                    {
                        foreach (var g in p.Grades)
                        {
                        }
                    }

                    var ex = Assert.Throws <AggregateException>(() => provider.Verify());
                    Assert.IsType <PossibleSlectPlusOneQueryException>(ex.InnerException);
                }
        }
        public void OneToOne()
        {
            using (var context = new SchoolContext(Options))
                using (var provider = new SelectPlusOneLoggerProvider(context, treshold: 2))
                {
                    var result = context
                                 .Person
                                 .Select(p => new
                    {
                        p.FirstName,
                        p.LastName,
                        p.OfficeAssignment.Location
                    }).ToList();

                    Assert.NotEmpty(result);
                    Assert.Contains(result, p => p.Location != null);

                    provider.Verify();
                }
        }