-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* New Query pipeline What works: Non-collection queries Sync/Async InMemory/Sqlite/SqlServer Method/Member translators Spatial What does not work: Cosmos provider - Tests are skipped in normal run so will fix later Collection queries - Includes/Correlated Subquery is not implemented yet Subquery lifting - Was dependent on nav rewrite A lot of small optimizations in expression tree/generated Sql Null semantics TPH Broader list at #14630 Notes: Old files are not deleted yet. (keeping them for reference for now) Still target NS2.0 Class names/namespaces are not final. Doc comments missing * Disabling tests
- Loading branch information
Showing
434 changed files
with
15,567 additions
and
7,379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/EFCore.Cosmos/Query/Pipeline/CosmosEntityQueryableTranslatorFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Query.Pipeline; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Pipeline | ||
{ | ||
public class CosmosEntityQueryableTranslatorFactory : EntityQueryableTranslatorFactory | ||
{ | ||
private readonly IModel _model; | ||
|
||
public CosmosEntityQueryableTranslatorFactory(IModel model) | ||
{ | ||
_model = model; | ||
} | ||
|
||
public override EntityQueryableTranslator Create(QueryCompilationContext2 queryCompilationContext) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
public class CosmosQueryableMethodTranslatingExpressionVisitorFactory : IQueryableMethodTranslatingExpressionVisitorFactory | ||
{ | ||
public QueryableMethodTranslatingExpressionVisitor Create(QueryCompilationContext2 queryCompilationContext) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
public class CosmosShapedQueryCompilingExpressionVisitorFactory : IShapedQueryCompilingExpressionVisitorFactory | ||
{ | ||
private readonly IEntityMaterializerSource _entityMaterializerSource; | ||
|
||
public CosmosShapedQueryCompilingExpressionVisitorFactory(IEntityMaterializerSource entityMaterializerSource) | ||
{ | ||
_entityMaterializerSource = entityMaterializerSource; | ||
} | ||
|
||
public ShapedQueryCompilingExpressionVisitor Create(QueryCompilationContext2 queryCompilationContext) | ||
{ | ||
throw new NotImplementedException(); | ||
//return new CosmosShapedQueryCompilingExpressionVisitor( | ||
// _entityMaterializerSource, | ||
// queryCompilationContext.TrackQueryResults, | ||
// queryCompilationContext.Async); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/EFCore.InMemory/Query/PipeLine/EntityValuesExpression.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Linq.Expressions; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
|
||
namespace Microsoft.EntityFrameworkCore.InMemory.Query.Pipeline | ||
{ | ||
public class EntityProjectionExpression : Expression | ||
{ | ||
public EntityProjectionExpression(IEntityType entityType, int startIndex) | ||
{ | ||
EntityType = entityType; | ||
StartIndex = startIndex; | ||
} | ||
|
||
public IEntityType EntityType { get; } | ||
public int StartIndex { get; } | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
src/EFCore.InMemory/Query/PipeLine/InMemoryEntityQueryableExpressionVisitor2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Query.Pipeline; | ||
|
||
namespace Microsoft.EntityFrameworkCore.InMemory.Query.Pipeline | ||
{ | ||
public class InMemoryEntityQueryableExpressionVisitor2 : EntityQueryableExpressionVisitor2 | ||
{ | ||
private readonly IModel _model; | ||
|
||
public InMemoryEntityQueryableExpressionVisitor2(IModel model) | ||
{ | ||
_model = model; | ||
} | ||
|
||
protected override ShapedQueryExpression CreateShapedQueryExpression(Type elementType) | ||
{ | ||
return new InMemoryShapedQueryExpression(_model.FindEntityType(elementType)); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/EFCore.InMemory/Query/PipeLine/InMemoryEntityQueryableExpressionVisitorFactory2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Query.Pipeline; | ||
|
||
namespace Microsoft.EntityFrameworkCore.InMemory.Query.Pipeline | ||
{ | ||
public class InMemoryEntityQueryableTranslatorFactory : EntityQueryableTranslatorFactory | ||
{ | ||
private readonly IModel _model; | ||
|
||
public InMemoryEntityQueryableTranslatorFactory(IModel model) | ||
{ | ||
_model = model; | ||
} | ||
|
||
public override EntityQueryableTranslator Create(QueryCompilationContext2 queryCompilationContext) | ||
{ | ||
return new InMemoryEntityQueryableTranslator(_model); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/EFCore.InMemory/Query/PipeLine/InMemoryEntityQueryableExpressionVisitors.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Collections.Generic; | ||
using System.Linq.Expressions; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Query.Pipeline; | ||
|
||
namespace Microsoft.EntityFrameworkCore.InMemory.Query.Pipeline | ||
{ | ||
public class InMemoryEntityQueryableTranslator : EntityQueryableTranslator | ||
{ | ||
private readonly IModel _model; | ||
|
||
public InMemoryEntityQueryableTranslator(IModel model) | ||
{ | ||
_model = model; | ||
} | ||
|
||
public override Expression Visit(Expression query) | ||
{ | ||
return new InMemoryEntityQueryableExpressionVisitor2(_model).Visit(query); | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/EFCore.InMemory/Query/PipeLine/InMemoryLinqOperatorProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using Microsoft.EntityFrameworkCore.Utilities; | ||
|
||
namespace Microsoft.EntityFrameworkCore.InMemory.Query.Pipeline | ||
{ | ||
public static class InMemoryLinqOperatorProvider | ||
{ | ||
private static MethodInfo GetMethod(string name, int parameterCount = 0) | ||
=> GetMethods(name, parameterCount).Single(); | ||
|
||
private static IEnumerable<MethodInfo> GetMethods(string name, int parameterCount = 0) | ||
=> typeof(Enumerable).GetTypeInfo().GetDeclaredMethods(name) | ||
.Where(mi => mi.GetParameters().Length == parameterCount + 1); | ||
|
||
public static MethodInfo Where = GetMethods(nameof(Enumerable.Where), 1) | ||
.Single(mi => mi.GetParameters()[1].ParameterType.GetGenericArguments().Length == 2); | ||
public static MethodInfo Select = GetMethods(nameof(Enumerable.Select), 1) | ||
.Single(mi => mi.GetParameters()[1].ParameterType.GetGenericArguments().Length == 2); | ||
|
||
public static MethodInfo Join = GetMethod(nameof(Enumerable.Join), 4); | ||
public static MethodInfo Contains = GetMethod(nameof(Enumerable.Contains), 1); | ||
|
||
public static MethodInfo OrderBy = GetMethod(nameof(Enumerable.OrderBy), 1); | ||
public static MethodInfo OrderByDescending = GetMethod(nameof(Enumerable.OrderByDescending), 1); | ||
public static MethodInfo ThenBy = GetMethod(nameof(Enumerable.ThenBy), 1); | ||
public static MethodInfo ThenByDescending = GetMethod(nameof(Enumerable.ThenByDescending), 1); | ||
public static MethodInfo All = GetMethod(nameof(Enumerable.All), 1); | ||
public static MethodInfo Any = GetMethod(nameof(Enumerable.Any)); | ||
public static MethodInfo AnyPredicate = GetMethod(nameof(Enumerable.Any), 1); | ||
public static MethodInfo Count = GetMethod(nameof(Enumerable.Count)); | ||
public static MethodInfo LongCount = GetMethod(nameof(Enumerable.LongCount)); | ||
public static MethodInfo CountPredicate = GetMethod(nameof(Enumerable.Count), 1); | ||
public static MethodInfo LongCountPredicate = GetMethod(nameof(Enumerable.LongCount), 1); | ||
public static MethodInfo Distinct = GetMethod(nameof(Enumerable.Distinct)); | ||
public static MethodInfo Take = GetMethod(nameof(Enumerable.Take), 1); | ||
public static MethodInfo Skip = GetMethod(nameof(Enumerable.Skip), 1); | ||
|
||
public static MethodInfo FirstPredicate = GetMethod(nameof(Enumerable.First), 1); | ||
public static MethodInfo FirstOrDefaultPredicate = GetMethod(nameof(Enumerable.FirstOrDefault), 1); | ||
public static MethodInfo LastPredicate = GetMethod(nameof(Enumerable.Last), 1); | ||
public static MethodInfo LastOrDefaultPredicate = GetMethod(nameof(Enumerable.LastOrDefault), 1); | ||
public static MethodInfo SinglePredicate = GetMethod(nameof(Enumerable.Single), 1); | ||
public static MethodInfo SingleOrDefaultPredicate = GetMethod(nameof(Enumerable.SingleOrDefault), 1); | ||
|
||
public static MethodInfo GetAggregateMethod(string methodName, Type elementType, int parameterCount = 0) | ||
{ | ||
Check.NotEmpty(methodName, nameof(methodName)); | ||
Check.NotNull(elementType, nameof(elementType)); | ||
|
||
var aggregateMethods = GetMethods(methodName, parameterCount).ToList(); | ||
|
||
return | ||
aggregateMethods | ||
.Single( | ||
mi => mi.GetParameters().Last().ParameterType.GetGenericArguments().Last() == elementType); | ||
//?? aggregateMethods.Single(mi => mi.IsGenericMethod) | ||
// .MakeGenericMethod(elementType); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.