public static IQueryable <TEntity> EagerLoadMatching <TEntity>(this IQueryable <TEntity> query, DbContext dbContext, Predicate <EagerLoadContext> includeStrategyPredicate, IncludeExecution includeExecution, params string[] navigationPropertiesToIgnore) where TEntity : class { var includeStrategy = new PredicateIncludeStrategy(includeStrategyPredicate); return(query.EagerLoadWithStrategy(dbContext, includeStrategy, includeExecution, navigationPropertiesToIgnore)); }
public void ShouldUseSuppliedPathPredicate_ToTestIfTheNavigationShouldBeIncluded() { var pathChecked = string.Empty; var strategy = new PredicateIncludeStrategy(path => { pathChecked = path; return(true); }); var context = new EagerLoadContext(Mock.Of <DbContext>(), strategy); var navigationMock = new Mock <INavigation>(); navigationMock.Setup(nav => nav.Name).Returns(nameof(Book)); context.SetCurrentNavigation(navigationMock.Object); Assert.True(strategy.ShouldIncludeCurrentNavigation(context)); Assert.Equal(nameof(Book), pathChecked); }
public void ShouldUseSuppliedContextPredicate_ToTestIfTheNavigationShouldBeIncluded() { var testCount = 0; var strategy = new PredicateIncludeStrategy((EagerLoadContext contextInput) => { var result = (testCount == 1); testCount++; return(result); }); var context = new EagerLoadContext(Mock.Of <DbContext>(), strategy); var navigationMock = new Mock <INavigation>(); navigationMock.Setup(nav => nav.Name).Returns(nameof(Book)); context.SetCurrentNavigation(navigationMock.Object); Assert.False(strategy.ShouldIncludeCurrentNavigation(context)); Assert.True(strategy.ShouldIncludeCurrentNavigation(context)); Assert.Equal(2, testCount); }