Skip to content

Commit

Permalink
Rename IsEagerLoaded to AutoInclude
Browse files Browse the repository at this point in the history
Part of #20409
  • Loading branch information
smitpatel committed Jul 22, 2020
1 parent 2cf65e9 commit 30a0366
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 73 deletions.
10 changes: 5 additions & 5 deletions src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2655,11 +2655,11 @@ source.Provider is EntityQueryProvider

#endregion

#region Eager loaded navigations
#region Auto included navigations

internal static readonly MethodInfo IgnoreEagerLoadedNavigationsMethodInfo
internal static readonly MethodInfo IgnoreAutoIncludesMethodInfo
= typeof(EntityFrameworkQueryableExtensions)
.GetTypeInfo().GetDeclaredMethod(nameof(IgnoreEagerLoadedNavigations));
.GetTypeInfo().GetDeclaredMethod(nameof(IgnoreAutoIncludes));

/// <summary>
/// Specifies that the current Entity Framework LINQ query should not have any
Expand All @@ -2670,7 +2670,7 @@ internal static readonly MethodInfo IgnoreEagerLoadedNavigationsMethodInfo
/// <returns>
/// A new query that will not apply any model-level eager loaded navigations.
/// </returns>
public static IQueryable<TEntity> IgnoreEagerLoadedNavigations<TEntity>(
public static IQueryable<TEntity> IgnoreAutoIncludes<TEntity>(
[NotNull] this IQueryable<TEntity> source)
where TEntity : class
{
Expand All @@ -2681,7 +2681,7 @@ source.Provider is EntityQueryProvider
? source.Provider.CreateQuery<TEntity>(
Expression.Call(
instance: null,
method: IgnoreEagerLoadedNavigationsMethodInfo.MakeGenericMethod(typeof(TEntity)),
method: IgnoreAutoIncludesMethodInfo.MakeGenericMethod(typeof(TEntity)),
arguments: source.Expression))
: source;
}
Expand Down
14 changes: 7 additions & 7 deletions src/EFCore/Metadata/Builders/IConventionNavigationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,23 @@ public interface IConventionNavigationBuilder : IConventionAnnotatableBuilder
IConventionNavigationBuilder UsePropertyAccessMode(PropertyAccessMode? propertyAccessMode, bool fromDataAnnotation = false);

/// <summary>
/// Returns a value indicating whether this navigation can be configured to be eager loaded in a query
/// Returns a value indicating whether this navigation can be configured to be automatically included in a query
/// from the current configuration source.
/// </summary>
/// <param name="eagerLoaded"> A value indicating whether the navigation should be eager loaded. </param>
/// <param name="autoInclude"> A value indicating whether the navigation should be automatically included. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns> <see langword="true" /> if eager loaded can be set for this navigation. </returns>
bool CanSetIsEagerLoaded(bool? eagerLoaded, bool fromDataAnnotation = false);
/// <returns> <see langword="true" /> if automatically included can be set for this navigation. </returns>
bool CanSetAutoInclude(bool? autoInclude, bool fromDataAnnotation = false);

/// <summary>
/// Configures this navigation to be eager loaded in a query
/// Configures this navigation to be automatically included in a query.
/// </summary>
/// <param name="eagerLoaded"> A value indicating whether the navigation should be eager loaded. </param>
/// <param name="autoInclude"> A value indicating whether the navigation should be automatically included. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns>
/// The same builder instance if the configuration was applied,
/// <see langword="null" /> otherwise.
/// </returns>
IConventionNavigationBuilder IsEagerLoaded(bool? eagerLoaded, bool fromDataAnnotation = false);
IConventionNavigationBuilder AutoInclude(bool? autoInclude, bool fromDataAnnotation = false);
}
}
14 changes: 7 additions & 7 deletions src/EFCore/Metadata/Builders/IConventionSkipNavigationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,23 @@ public interface IConventionSkipNavigationBuilder : IConventionAnnotatableBuilde
bool CanSetInverse([CanBeNull] IConventionSkipNavigation inverse, bool fromDataAnnotation = false);

/// <summary>
/// Returns a value indicating whether this navigation can be configured to be eager loaded in a query
/// Returns a value indicating whether this navigation can be configured to be automatically included in a query
/// from the current configuration source.
/// </summary>
/// <param name="eagerLoaded"> A value indicating whether the navigation should be eager loaded. </param>
/// <param name="autoInclude"> A value indicating whether the navigation should be automatically included. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns> <see langword="true" /> if eager loaded can be set for this navigation. </returns>
bool CanSetIsEagerLoaded(bool? eagerLoaded, bool fromDataAnnotation = false);
/// <returns> <see langword="true" /> if automatically included can be set for this navigation. </returns>
bool CanSetAutoInclude(bool? autoInclude, bool fromDataAnnotation = false);

/// <summary>
/// Configures this navigation to be eager loaded in a query
/// Configures this navigation to be automatically included in a query.
/// </summary>
/// <param name="eagerLoaded"> A value indicating whether the navigation should be eager loaded. </param>
/// <param name="autoInclude"> A value indicating whether the navigation should be automatically included. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns>
/// The same builder instance if the configuration was applied,
/// <see langword="null" /> otherwise.
/// </returns>
IConventionSkipNavigationBuilder IsEagerLoaded(bool? eagerLoaded, bool fromDataAnnotation = false);
IConventionSkipNavigationBuilder AutoInclude(bool? autoInclude, bool fromDataAnnotation = false);
}
}
10 changes: 5 additions & 5 deletions src/EFCore/Metadata/Builders/NavigationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,19 @@ public virtual NavigationBuilder HasField([CanBeNull] string fieldName)
}

/// <summary>
/// Configures whether this navigation should be eager loaded in a query.
/// Configures whether this navigation should be automatically included in a query.
/// </summary>
/// <param name="eagerLoaded"> A value indicating if the navigation should be eager loaded. </param>
/// <param name="autoInclude"> A value indicating if the navigation should be automatically included. </param>
/// <returns> The same builder instance so that multiple configuration calls can be chained. </returns>
public virtual NavigationBuilder IsEagerLoaded(bool eagerLoaded = true)
public virtual NavigationBuilder AutoInclude(bool autoInclude = true)
{
if (InternalNavigationBuilder != null)
{
InternalNavigationBuilder.IsEagerLoaded(eagerLoaded, ConfigurationSource.Explicit);
InternalNavigationBuilder.AutoInclude(autoInclude, ConfigurationSource.Explicit);
}
else
{
InternalSkipNavigationBuilder.IsEagerLoaded(eagerLoaded, ConfigurationSource.Explicit);
InternalSkipNavigationBuilder.AutoInclude(autoInclude, ConfigurationSource.Explicit);
}

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public NavigationEagerLoadingConvention([NotNull] ProviderConventionSetBuilderDe
public virtual void ProcessForeignKeyOwnershipChanged(
IConventionForeignKeyBuilder relationshipBuilder, IConventionContext<bool?> context)
{
relationshipBuilder.Metadata.PrincipalToDependent?.Builder.IsEagerLoaded(relationshipBuilder.Metadata.IsOwnership);
relationshipBuilder.Metadata.PrincipalToDependent?.Builder.AutoInclude(relationshipBuilder.Metadata.IsOwnership);
}
}
}
18 changes: 9 additions & 9 deletions src/EFCore/Metadata/Internal/InternalNavigationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public InternalNavigationBuilder([NotNull] Navigation metadata, [NotNull] Intern
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool CanSetIsEagerLoaded(bool? eagerLoaded, ConfigurationSource configurationSource)
public virtual bool CanSetAutoInclude(bool? autoInclude, ConfigurationSource configurationSource)
{
IConventionNavigation conventionNavigation = Metadata;

return configurationSource.Overrides(conventionNavigation.GetIsEagerLoadedConfigurationSource())
|| conventionNavigation.IsEagerLoaded == eagerLoaded;
|| conventionNavigation.IsEagerLoaded == autoInclude;
}

/// <summary>
Expand All @@ -75,11 +75,11 @@ public virtual bool CanSetIsEagerLoaded(bool? eagerLoaded, ConfigurationSource c
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual InternalNavigationBuilder IsEagerLoaded(bool? eagerLoaded, ConfigurationSource configurationSource)
public virtual InternalNavigationBuilder AutoInclude(bool? autoInclude, ConfigurationSource configurationSource)
{
if (CanSetIsEagerLoaded(eagerLoaded, configurationSource))
if (CanSetAutoInclude(autoInclude, configurationSource))
{
Metadata.SetIsEagerLoaded(eagerLoaded, configurationSource);
Metadata.SetIsEagerLoaded(autoInclude, configurationSource);

return this;
}
Expand Down Expand Up @@ -136,12 +136,12 @@ IConventionNavigationBuilder IConventionNavigationBuilder.HasField(FieldInfo fie

/// <inheritdoc />
[DebuggerStepThrough]
bool IConventionNavigationBuilder.CanSetIsEagerLoaded(bool? eagerLoaded, bool fromDataAnnotation)
=> CanSetIsEagerLoaded(eagerLoaded, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
bool IConventionNavigationBuilder.CanSetAutoInclude(bool? autoInclude, bool fromDataAnnotation)
=> CanSetAutoInclude(autoInclude, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);

/// <inheritdoc />
[DebuggerStepThrough]
IConventionNavigationBuilder IConventionNavigationBuilder.IsEagerLoaded(bool? eagerLoaded, bool fromDataAnnotation)
=> IsEagerLoaded(eagerLoaded, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
IConventionNavigationBuilder IConventionNavigationBuilder.AutoInclude(bool? autoInclude, bool fromDataAnnotation)
=> AutoInclude(autoInclude, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
}
}
18 changes: 9 additions & 9 deletions src/EFCore/Metadata/Internal/InternalSkipNavigationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,12 @@ public virtual InternalSkipNavigationBuilder Attach(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool CanSetIsEagerLoaded(bool? eagerLoaded, ConfigurationSource configurationSource)
public virtual bool CanSetAutoInclude(bool? autoInclude, ConfigurationSource configurationSource)
{
IConventionSkipNavigation conventionNavigation = Metadata;

return configurationSource.Overrides(conventionNavigation.GetIsEagerLoadedConfigurationSource())
|| conventionNavigation.IsEagerLoaded == eagerLoaded;
|| conventionNavigation.IsEagerLoaded == autoInclude;
}

/// <summary>
Expand All @@ -301,11 +301,11 @@ public virtual bool CanSetIsEagerLoaded(bool? eagerLoaded, ConfigurationSource c
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual InternalSkipNavigationBuilder IsEagerLoaded(bool? eagerLoaded, ConfigurationSource configurationSource)
public virtual InternalSkipNavigationBuilder AutoInclude(bool? autoInclude, ConfigurationSource configurationSource)
{
if (CanSetIsEagerLoaded(eagerLoaded, configurationSource))
if (CanSetAutoInclude(autoInclude, configurationSource))
{
Metadata.SetIsEagerLoaded(eagerLoaded, configurationSource);
Metadata.SetIsEagerLoaded(autoInclude, configurationSource);

return this;
}
Expand Down Expand Up @@ -396,12 +396,12 @@ bool IConventionSkipNavigationBuilder.CanSetInverse(

/// <inheritdoc />
[DebuggerStepThrough]
bool IConventionSkipNavigationBuilder.CanSetIsEagerLoaded(bool? eagerLoaded, bool fromDataAnnotation)
=> CanSetIsEagerLoaded(eagerLoaded, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
bool IConventionSkipNavigationBuilder.CanSetAutoInclude(bool? autoInclude, bool fromDataAnnotation)
=> CanSetAutoInclude(autoInclude, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);

/// <inheritdoc />
[DebuggerStepThrough]
IConventionSkipNavigationBuilder IConventionSkipNavigationBuilder.IsEagerLoaded(bool? eagerLoaded, bool fromDataAnnotation)
=> IsEagerLoaded(eagerLoaded, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
IConventionSkipNavigationBuilder IConventionSkipNavigationBuilder.AutoInclude(bool? autoInclude, bool fromDataAnnotation)
=> AutoInclude(autoInclude, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@ var outboundNavigations
.Concat(entityType.GetDerivedSkipNavigations())
.Where(n => n.IsEagerLoaded);

if (_queryCompilationContext.IgnoreEagerLoadedNavigations)
if (_queryCompilationContext.IgnoreAutoIncludes)
{
outboundNavigations = outboundNavigations.Where(n => n is INavigation navigation && navigation.ForeignKey.IsOwnership);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ private Expression ExtractQueryMetadata(MethodCallExpression methodCallExpressio
return visitedExpression;
}

if (genericMethodDefinition == EntityFrameworkQueryableExtensions.IgnoreEagerLoadedNavigationsMethodInfo)
if (genericMethodDefinition == EntityFrameworkQueryableExtensions.IgnoreAutoIncludesMethodInfo)
{
var visitedExpression = Visit(methodCallExpression.Arguments[0]);
_queryCompilationContext.IgnoreEagerLoadedNavigations = true;
_queryCompilationContext.IgnoreAutoIncludes = true;

return visitedExpression;
}
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore/Query/QueryCompilationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public QueryCompilationContext(
/// <summary>
/// A value indicating whether eager loaded navigations are ignored in this query.
/// </summary>
public virtual bool IgnoreEagerLoadedNavigations { get; internal set; }
public virtual bool IgnoreAutoIncludes { get; internal set; }
/// <summary>
/// The set of tags applied to this query.
/// </summary>
Expand Down
12 changes: 6 additions & 6 deletions test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7623,7 +7623,7 @@ public BugContext21355(DbContextOptions options)
#region Issue21540

[ConditionalFact]
public virtual void Can_eager_loaded_navigation_from_model()
public virtual void Can_auto_include_navigation_from_model()
{
using (CreateDatabase21540())
{
Expand Down Expand Up @@ -7653,12 +7653,12 @@ FROM [JoinEntity21540] AS [j]
}

[ConditionalFact]
public virtual void Can_ignore_eager_loaded_navigation_from_model()
public virtual void Can_ignore_auto_included_navigation_from_model()
{
using (CreateDatabase21540())
{
using var context = new MyContext21540(_options);
var query = context.Parents.AsNoTracking().IgnoreEagerLoadedNavigations().ToList();
var query = context.Parents.AsNoTracking().IgnoreAutoIncludes().ToList();

var result = Assert.Single(query);
Assert.NotNull(result.OwnedReference);
Expand Down Expand Up @@ -7732,9 +7732,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasKey(e => new { e.ParentId, e.OtherSideId });
modelBuilder.Entity<Parent21540>().OwnsOne(e => e.OwnedReference);

modelBuilder.Entity<Parent21540>().Navigation(e => e.Reference).IsEagerLoaded();
modelBuilder.Entity<Parent21540>().Navigation(e => e.Collection).IsEagerLoaded();
modelBuilder.Entity<Parent21540>().Navigation(e => e.SkipOtherSide).IsEagerLoaded();
modelBuilder.Entity<Parent21540>().Navigation(e => e.Reference).AutoInclude();
modelBuilder.Entity<Parent21540>().Navigation(e => e.Collection).AutoInclude();
modelBuilder.Entity<Parent21540>().Navigation(e => e.SkipOtherSide).AutoInclude();
}
}

Expand Down
Loading

0 comments on commit 30a0366

Please sign in to comment.