Added additional code docs

This commit is contained in:
Koen Bekkenutte
2021-11-15 20:44:47 +08:00
parent 97bbc003fe
commit ac338aa3a0
5 changed files with 23 additions and 0 deletions
@@ -13,10 +13,16 @@ namespace Microsoft.EntityFrameworkCore
{
public static class DbContextOptionsExtensions
{
/// <summary>
/// Use projectables within the queries. Any call to a Projectable property/method will automatically be translated to the underlying expression tree instead
/// </summary>
public static DbContextOptionsBuilder<TContext> UseProjectables<TContext>(this DbContextOptionsBuilder<TContext> optionsBuilder, Action<ProjectableOptionsBuilder>? configure = null)
where TContext : DbContext
=> (DbContextOptionsBuilder<TContext>)UseProjectables((DbContextOptionsBuilder)optionsBuilder, configure);
/// <summary>
/// Use projectables within the queries. Any call to a Projectable property/method will automatically be translated to the underlying expression tree instead
/// </summary>
public static DbContextOptionsBuilder UseProjectables(this DbContextOptionsBuilder optionsBuilder, Action<ProjectableOptionsBuilder>? configure = null)
{
var extension = optionsBuilder.Options.FindExtension<ProjectionOptionsExtension>() ?? new ProjectionOptionsExtension();
@@ -16,6 +16,9 @@ namespace EntityFrameworkCore.Projectables.Extensions
public static Expression ExpandQuaryables(this Expression expression)
=> ExpandProjectables(expression);
/// <summary>
/// Replaces all calls to properties and methods that are marked with the <C>Projectable</C> attribute with their respective expression tree
/// </summary>
public static Expression ExpandProjectables(this Expression expression)
=> _projectableExpressionReplacer.Visit(expression);
}
@@ -13,6 +13,9 @@ namespace EntityFrameworkCore.Projectables.Extensions
public static IQueryable<TModel> ExpandQuaryables<TModel>(this IQueryable<TModel> query)
=> ExpandProjectables(query);
/// <summary>
/// Replaces all calls to properties and methods that are marked with the <C>Projectable</C> attribute with their respective expression tree
/// </summary>
public static IQueryable<TModel> ExpandProjectables<TModel>(this IQueryable<TModel> query)
=> query.Provider.CreateQuery<TModel>(query.Expression.ExpandProjectables());
}
@@ -8,7 +8,15 @@ namespace EntityFrameworkCore.Projectables.Infrastructure
{
public enum CompatibilityMode
{
/// <summary>
/// Projectables are expanded on each individual query invocation.
/// This mode can be used when you wan't to pass scoped services to your Projectable methods
/// </summary>
Full,
/// <summary>
/// Projectables are expanded in the query preprocessor and afterwards cached.
/// This is the default compatibility mode.
/// </summary>
Limited
}
}
@@ -18,6 +18,9 @@ namespace EntityFrameworkCore.Projectables.Infrastructure
_optionsBuilder = optionsBuilder ?? throw new ArgumentNullException(nameof(optionsBuilder));
}
/// <summary>
/// Change the default CompatibilityMode
/// </summary>
public ProjectableOptionsBuilder CompatibilityMode(CompatibilityMode mode)
=> WithOption(x => x.WithCompatibilityMode(mode));