mirror of
https://github.com/zoriya/EntityFrameworkCore.Projectables.git
synced 2026-08-15 18:44:57 +00:00
Merge pull request #8 from koenbeuk/missing-docs
Added minimal docs on the projectable attribute
This commit is contained in:
@@ -6,9 +6,16 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace EntityFrameworkCore.Projectables
|
namespace EntityFrameworkCore.Projectables
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Declares this property or method to be Projectable.
|
||||||
|
/// A companion Expression tree will be generated
|
||||||
|
/// </summary>
|
||||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
|
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
|
||||||
public sealed class ProjectableAttribute : Attribute
|
public sealed class ProjectableAttribute : Attribute
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Get or set how null-conditional operators are handeled
|
||||||
|
/// </summary>
|
||||||
public NullConditionalRewriteSupport NullConditionalRewriteSupport { get; set; }
|
public NullConditionalRewriteSupport NullConditionalRewriteSupport { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-4
@@ -15,8 +15,4 @@
|
|||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisVersion)" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisVersion)" PrivateAssets="all" />
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Internal\" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -13,10 +13,16 @@ namespace Microsoft.EntityFrameworkCore
|
|||||||
{
|
{
|
||||||
public static class DbContextOptionsExtensions
|
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)
|
public static DbContextOptionsBuilder<TContext> UseProjectables<TContext>(this DbContextOptionsBuilder<TContext> optionsBuilder, Action<ProjectableOptionsBuilder>? configure = null)
|
||||||
where TContext : DbContext
|
where TContext : DbContext
|
||||||
=> (DbContextOptionsBuilder<TContext>)UseProjectables((DbContextOptionsBuilder)optionsBuilder, configure);
|
=> (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)
|
public static DbContextOptionsBuilder UseProjectables(this DbContextOptionsBuilder optionsBuilder, Action<ProjectableOptionsBuilder>? configure = null)
|
||||||
{
|
{
|
||||||
var extension = optionsBuilder.Options.FindExtension<ProjectionOptionsExtension>() ?? new ProjectionOptionsExtension();
|
var extension = optionsBuilder.Options.FindExtension<ProjectionOptionsExtension>() ?? new ProjectionOptionsExtension();
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ namespace EntityFrameworkCore.Projectables.Extensions
|
|||||||
public static Expression ExpandQuaryables(this Expression expression)
|
public static Expression ExpandQuaryables(this Expression expression)
|
||||||
=> ExpandProjectables(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)
|
public static Expression ExpandProjectables(this Expression expression)
|
||||||
=> _projectableExpressionReplacer.Visit(expression);
|
=> _projectableExpressionReplacer.Visit(expression);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ namespace EntityFrameworkCore.Projectables.Extensions
|
|||||||
public static IQueryable<TModel> ExpandQuaryables<TModel>(this IQueryable<TModel> query)
|
public static IQueryable<TModel> ExpandQuaryables<TModel>(this IQueryable<TModel> query)
|
||||||
=> ExpandProjectables(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)
|
public static IQueryable<TModel> ExpandProjectables<TModel>(this IQueryable<TModel> query)
|
||||||
=> query.Provider.CreateQuery<TModel>(query.Expression.ExpandProjectables());
|
=> query.Provider.CreateQuery<TModel>(query.Expression.ExpandProjectables());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,15 @@ namespace EntityFrameworkCore.Projectables.Infrastructure
|
|||||||
{
|
{
|
||||||
public enum CompatibilityMode
|
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,
|
Full,
|
||||||
|
/// <summary>
|
||||||
|
/// Projectables are expanded in the query preprocessor and afterwards cached.
|
||||||
|
/// This is the default compatibility mode.
|
||||||
|
/// </summary>
|
||||||
Limited
|
Limited
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ namespace EntityFrameworkCore.Projectables.Infrastructure
|
|||||||
_optionsBuilder = optionsBuilder ?? throw new ArgumentNullException(nameof(optionsBuilder));
|
_optionsBuilder = optionsBuilder ?? throw new ArgumentNullException(nameof(optionsBuilder));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Change the default CompatibilityMode
|
||||||
|
/// </summary>
|
||||||
public ProjectableOptionsBuilder CompatibilityMode(CompatibilityMode mode)
|
public ProjectableOptionsBuilder CompatibilityMode(CompatibilityMode mode)
|
||||||
=> WithOption(x => x.WithCompatibilityMode(mode));
|
=> WithOption(x => x.WithCompatibilityMode(mode));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user