Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add query documentation in EF Core #20573

Merged
merged 1 commit into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
<PackageProjectUrl>https://docs.microsoft.com/ef/core/</PackageProjectUrl>
</PropertyGroup>

<!-- HACK: Work around #15093 -->
<PropertyGroup>
<NoWarn>$(NoWarn.Replace(';1591', ''))</NoWarn>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="**\*.rd.xml" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public static void ExecutingSqlQuery(
cosmosSqlQuery.Query);
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 static void ExecutingReadItem(
[NotNull] this IDiagnosticsLogger<DbLoggerCategory.Database.Command> diagnosticsLogger,
[NotNull] string partitionKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ public virtual CosmosOptionsExtension WithExecutionStrategyFactory(
/// </summary>
protected virtual CosmosOptionsExtension Clone() => new CosmosOptionsExtension(this);

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 void ApplyServices(IServiceCollection services)
=> services.AddEntityFrameworkCosmos();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public interface ICosmosSingletonOptions : ISingletonOptions
/// </summary>
string Region { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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>
ConnectionMode? ConnectionMode { get; }
}
}
2 changes: 2 additions & 0 deletions src/EFCore.Cosmos/Metadata/Conventions/StoreKeyConvention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ public class StoreKeyConvention :
IEntityTypeAnnotationChangedConvention,
IEntityTypeBaseTypeChangedConvention
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public static readonly string IdPropertyName = "id";
public static readonly string JObjectPropertyName = "__jObject";
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member

/// <summary>
/// Creates a new instance of <see cref="StoreKeyConvention" />.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ protected override Expression VisitMember(MemberExpression memberExpression)
}
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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>
protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression)
{
Check.NotNull(methodCallExpression, nameof(methodCallExpression));
Expand Down
23 changes: 20 additions & 3 deletions src/EFCore.Cosmos/Query/Internal/CosmosQueryCompilationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,32 @@

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 class CosmosQueryCompilationContext : QueryCompilationContext
{
public virtual string PartitionKeyFromExtension { get; internal set; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 CosmosQueryCompilationContext(
[NotNull] QueryCompilationContextDependencies dependencies, bool async)
: base(dependencies, async)
{

}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 string PartitionKeyFromExtension { get; internal set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
/// <para>
/// A factory for creating <see cref="CosmosQueryCompilationContext" /> instances.
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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.
/// </para>
/// <para>
/// The service lifetime is <see cref="ServiceLifetime.Scoped" />. This means that each
Expand All @@ -23,12 +26,24 @@ public class CosmosQueryCompilationContextFactory : IQueryCompilationContextFact
{
private readonly QueryCompilationContextDependencies _dependencies;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 CosmosQueryCompilationContextFactory([NotNull] QueryCompilationContextDependencies dependencies)
{
Check.NotNull(dependencies, nameof(dependencies));
_dependencies = dependencies;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 QueryCompilationContext Create(bool async)
=> new CosmosQueryCompilationContext(_dependencies, async);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,34 @@

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 class CosmosQueryMetadataExtractingExpressionVisitor : ExpressionVisitor
{
private readonly CosmosQueryCompilationContext _cosmosQueryCompilationContext;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 CosmosQueryMetadataExtractingExpressionVisitor([NotNull] CosmosQueryCompilationContext cosmosQueryCompilationContext)
{
Check.NotNull(cosmosQueryCompilationContext, nameof(cosmosQueryCompilationContext));
_cosmosQueryCompilationContext = cosmosQueryCompilationContext;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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>
protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression)
{
if (methodCallExpression.Method.IsGenericMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 class CosmosQueryTranslationPreprocessor : QueryTranslationPreprocessor
{

private readonly CosmosQueryCompilationContext _queryCompilationContext;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 CosmosQueryTranslationPreprocessor(
[NotNull] QueryTranslationPreprocessorDependencies dependencies,
[NotNull] CosmosQueryCompilationContext cosmosQueryCompilationContext)
Expand All @@ -20,9 +31,15 @@ public CosmosQueryTranslationPreprocessor(
_queryCompilationContext = cosmosQueryCompilationContext;
}

public override Expression NormalizeQueryableMethodCall(Expression query)
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 override Expression NormalizeQueryableMethod(Expression query)
{
query = base.NormalizeQueryableMethodCall(query);
query = base.NormalizeQueryableMethod(query);

query = new CosmosQueryMetadataExtractingExpressionVisitor(_queryCompilationContext).Visit(query);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
/// <para>
/// A factory for creating <see cref="CosmosQueryTranslationPreprocessor" /> instances.
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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.
/// </para>
/// <para>
/// The service lifetime is <see cref="ServiceLifetime.Singleton" />. This means a single instance
Expand All @@ -22,13 +25,25 @@ public class CosmosQueryTranslationPreprocessorFactory : IQueryTranslationPrepro
{
private readonly QueryTranslationPreprocessorDependencies _dependencies;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 CosmosQueryTranslationPreprocessorFactory(
[NotNull] QueryTranslationPreprocessorDependencies dependencies)
{
Check.NotNull(dependencies, nameof(dependencies));
_dependencies = dependencies;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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 QueryTranslationPreprocessor Create(QueryCompilationContext queryCompilationContext)
=> new CosmosQueryTranslationPreprocessor(_dependencies, (CosmosQueryCompilationContext)queryCompilationContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public CosmosQueryableMethodTranslatingExpressionVisitor(
[NotNull] ISqlExpressionFactory sqlExpressionFactory,
[NotNull] IMemberTranslatorProvider memberTranslatorProvider,
[NotNull] IMethodCallTranslatorProvider methodCallTranslatorProvider)
: base(dependencies, subquery: false)
: base(dependencies, queryCompilationContext, subquery: false)
{
_model = queryCompilationContext.Model;
_sqlExpressionFactory = sqlExpressionFactory;
Expand All @@ -62,7 +62,7 @@ public CosmosQueryableMethodTranslatingExpressionVisitor(
/// </summary>
protected CosmosQueryableMethodTranslatingExpressionVisitor(
[NotNull] CosmosQueryableMethodTranslatingExpressionVisitor parentVisitor)
: base(parentVisitor.Dependencies, subquery: true)
: base(parentVisitor.Dependencies, parentVisitor.QueryCompilationContext, subquery: true)
{
_model = parentVisitor._model;
_sqlExpressionFactory = parentVisitor._sqlExpressionFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery

selectExpression.ApplyProjection();

shaperBody = new CosmosProjectionBindingRemovingExpressionVisitor(selectExpression, jObjectParameter, IsTracking)
shaperBody = new CosmosProjectionBindingRemovingExpressionVisitor(
selectExpression, jObjectParameter, QueryCompilationContext.IsTracking)
.Visit(shaperBody);

var shaperLambda = Expression.Lambda(
Expand All @@ -90,8 +91,8 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery

case ReadItemExpression readItemExpression:

shaperBody =
new CosmosProjectionBindingRemovingReadItemExpressionVisitor(readItemExpression, jObjectParameter, IsTracking)
shaperBody = new CosmosProjectionBindingRemovingReadItemExpressionVisitor(
readItemExpression, jObjectParameter, QueryCompilationContext.IsTracking)
.Visit(shaperBody);

var shaperReadItemLambda = Expression.Lambda(
Expand All @@ -108,7 +109,7 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery
Expression.Constant(shaperReadItemLambda.Compile()),
Expression.Constant(_contextType),
Expression.Constant(_logger));

default:
throw new NotImplementedException();
}
Expand Down
6 changes: 3 additions & 3 deletions src/EFCore.Cosmos/Query/Internal/ReadItemExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ReadItemExpression : Expression
/// 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 override Type Type => typeof(JObject);
public override Type Type => typeof(object);

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down Expand Up @@ -60,7 +60,7 @@ public class ReadItemExpression : Expression
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual IEntityType EntityType { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand All @@ -83,7 +83,7 @@ public ReadItemExpression(
Check.NotNull(propertyParameters, nameof(propertyParameters));

Container = entityType.GetContainer();

ProjectionExpression = new ProjectionExpression(
new EntityProjectionExpression(
entityType,
Expand Down
Loading