Skip to content

Commit

Permalink
Work on Cosmos primitive collections, subquery and general query infra
Browse files Browse the repository at this point in the history
Implements dotnet#25701 for primitive collections
Implements dotnet#25700 for primitive collections
Largely implements dotnet#25765
Fixes dotnet#33858
  • Loading branch information
roji committed Jun 4, 2024
1 parent 16acc46 commit 8adc1a9
Show file tree
Hide file tree
Showing 49 changed files with 4,121 additions and 338 deletions.
20 changes: 12 additions & 8 deletions src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions src/EFCore.Cosmos/Properties/CosmosStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@
<data name="CanConnectNotSupported" xml:space="preserve">
<value>The Cosmos database does not support 'CanConnect' or 'CanConnectAsync'.</value>
</data>
<data name="CannotTranslateNonConstantNewArrayExpression" xml:space="preserve">
<value>The query contained a new array expression containing non-constant elements, which could not be translated: '{newArrayExpression}'.</value>
</data>
<data name="ConnectionInfoMissing" xml:space="preserve">
<value>None of connection string, CredentialToken, account key or account endpoint were specified. Specify a set of connection details.</value>
</data>
Expand All @@ -144,6 +141,9 @@
<data name="ETagNonStringStoreType" xml:space="preserve">
<value>The type of the etag property '{property}' on '{entityType}' is '{propertyType}'. All etag properties must be strings or have a string value converter.</value>
</data>
<data name="ExceptNotSupported" xml:space="preserve">
<value>The 'Except()' LINQ operator isn't supported by Cosmos.</value>
</data>
<data name="IdNonStringStoreType" xml:space="preserve">
<value>The type of the '{idProperty}' property on '{entityType}' is '{propertyType}'. All 'id' properties must be strings or have a string value converter.</value>
</data>
Expand Down Expand Up @@ -213,6 +213,9 @@
<data name="NoIdProperty" xml:space="preserve">
<value>The entity type '{entityType}' does not have a property mapped to the 'id' property in the database. Add a property mapped to 'id'.</value>
</data>
<data name="NonCorrelatedSubqueriesNotSupported" xml:space="preserve">
<value>Cosmos subqueries must be correlated, referencing values from the outer query.</value>
</data>
<data name="NonEmbeddedIncludeNotSupported" xml:space="preserve">
<value>Including navigation '{navigation}' is not supported as the navigation is not embedded in same resource.</value>
</data>
Expand Down
56 changes: 56 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/CosmosQueryRootProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

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 CosmosQueryRootProcessor : QueryRootProcessor
{
private readonly IModel _model;

/// <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 CosmosQueryRootProcessor(QueryTranslationPreprocessorDependencies dependencies, QueryCompilationContext queryCompilationContext)
: base(dependencies, queryCompilationContext)
{
_model = queryCompilationContext.Model;
}

/// <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 bool ShouldConvertToInlineQueryRoot(Expression expression)
=> true;

/// <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 bool ShouldConvertToParameterQueryRoot(ParameterExpression parameterExpression)
=> true;

/// <inheritdoc />
protected override Expression VisitExtension(Expression node)
=> node switch
{
// We skip FromSqlQueryRootExpression, since that contains the arguments as an object array parameter, and don't want to convert
// that to a query root
FromSqlQueryRootExpression e => e,

_ => base.VisitExtension(node)
};
}
Loading

0 comments on commit 8adc1a9

Please sign in to comment.