Skip to content

Commit 6d8c5a4

Browse files
committed
Merge branch 'release/8.0'
2 parents 24efb9c + 0222609 commit 6d8c5a4

File tree

40 files changed

+353
-184
lines changed

40 files changed

+353
-184
lines changed

eng/Version.Details.xml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Dependencies>
33
<ProductDependencies>
4-
<Dependency Name="Microsoft.Extensions.Caching.Memory" Version="8.0.0-rc.2.23426.4">
4+
<Dependency Name="Microsoft.Extensions.Caching.Memory" Version="8.0.0-rc.2.23430.5">
55
<Uri>https://github.com/dotnet/runtime</Uri>
6-
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
6+
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
77
</Dependency>
8-
<Dependency Name="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0-rc.2.23426.4">
8+
<Dependency Name="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0-rc.2.23430.5">
99
<Uri>https://github.com/dotnet/runtime</Uri>
10-
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
10+
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
1111
</Dependency>
12-
<Dependency Name="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0-rc.2.23426.4">
12+
<Dependency Name="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0-rc.2.23430.5">
1313
<Uri>https://github.com/dotnet/runtime</Uri>
14-
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
14+
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
1515
</Dependency>
16-
<Dependency Name="Microsoft.Extensions.Configuration.Json" Version="8.0.0-rc.2.23426.4">
16+
<Dependency Name="Microsoft.Extensions.Configuration.Json" Version="8.0.0-rc.2.23430.5">
1717
<Uri>https://github.com/dotnet/runtime</Uri>
18-
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
18+
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
1919
</Dependency>
20-
<Dependency Name="Microsoft.Extensions.Configuration" Version="8.0.0-rc.2.23426.4">
20+
<Dependency Name="Microsoft.Extensions.Configuration" Version="8.0.0-rc.2.23430.5">
2121
<Uri>https://github.com/dotnet/runtime</Uri>
22-
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
22+
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
2323
</Dependency>
24-
<Dependency Name="Microsoft.Extensions.DependencyInjection" Version="8.0.0-rc.2.23426.4">
24+
<Dependency Name="Microsoft.Extensions.DependencyInjection" Version="8.0.0-rc.2.23430.5">
2525
<Uri>https://github.com/dotnet/runtime</Uri>
26-
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
26+
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
2727
</Dependency>
28-
<Dependency Name="Microsoft.Extensions.DependencyModel" Version="8.0.0-rc.2.23426.4">
28+
<Dependency Name="Microsoft.Extensions.DependencyModel" Version="8.0.0-rc.2.23430.5">
2929
<Uri>https://github.com/dotnet/runtime</Uri>
30-
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
30+
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
3131
</Dependency>
32-
<Dependency Name="Microsoft.Extensions.HostFactoryResolver.Sources" Version="8.0.0-rc.2.23426.4">
32+
<Dependency Name="Microsoft.Extensions.HostFactoryResolver.Sources" Version="8.0.0-rc.2.23430.5">
3333
<Uri>https://github.com/dotnet/runtime</Uri>
34-
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
34+
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
3535
</Dependency>
36-
<Dependency Name="Microsoft.Extensions.Logging" Version="8.0.0-rc.2.23426.4">
36+
<Dependency Name="Microsoft.Extensions.Logging" Version="8.0.0-rc.2.23430.5">
3737
<Uri>https://github.com/dotnet/runtime</Uri>
38-
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
38+
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
3939
</Dependency>
40-
<Dependency Name="System.Text.Json" Version="8.0.0-rc.2.23426.4">
40+
<Dependency Name="System.Text.Json" Version="8.0.0-rc.2.23430.5">
4141
<Uri>https://github.com/dotnet/runtime</Uri>
42-
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
42+
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
4343
</Dependency>
44-
<Dependency Name="Microsoft.NETCore.App.Ref" Version="8.0.0-rc.2.23426.4">
44+
<Dependency Name="Microsoft.NETCore.App.Ref" Version="8.0.0-rc.2.23430.5">
4545
<Uri>https://github.com/dotnet/runtime</Uri>
46-
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
46+
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
4747
</Dependency>
48-
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="8.0.0-rc.2.23426.4">
48+
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="8.0.0-rc.2.23430.5">
4949
<Uri>https://github.com/dotnet/runtime</Uri>
50-
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
50+
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
5151
</Dependency>
5252
<!-- NB: Using BrowserDebugHost to represent the nonshipping version of Microsoft.NETCore.App -->
53-
<Dependency Name="Microsoft.NETCore.BrowserDebugHost.Transport" Version="8.0.0-rc.2.23426.4">
53+
<Dependency Name="Microsoft.NETCore.BrowserDebugHost.Transport" Version="8.0.0-rc.2.23430.5">
5454
<Uri>https://github.com/dotnet/runtime</Uri>
55-
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
55+
<Sha>40d2134aa50389d70fd845a7a6c06f46383e602e</Sha>
5656
</Dependency>
5757
</ProductDependencies>
5858
<ToolsetDependencies>

eng/Versions.props

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616
<UsingToolXliff>False</UsingToolXliff>
1717
</PropertyGroup>
1818
<PropertyGroup Label="Dependencies from dotnet/runtime">
19-
<MicrosoftExtensionsCachingMemoryVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsCachingMemoryVersion>
20-
<MicrosoftExtensionsConfigurationVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsConfigurationVersion>
21-
<MicrosoftExtensionsConfigurationAbstractionsVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsConfigurationAbstractionsVersion>
22-
<MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>
23-
<MicrosoftExtensionsConfigurationJsonVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsConfigurationJsonVersion>
24-
<MicrosoftExtensionsDependencyInjectionVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsDependencyInjectionVersion>
25-
<MicrosoftExtensionsDependencyModelVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsDependencyModelVersion>
26-
<MicrosoftExtensionsHostFactoryResolverSourcesVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsHostFactoryResolverSourcesVersion>
27-
<MicrosoftExtensionsLoggingVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsLoggingVersion>
28-
<SystemTextJsonVersion>8.0.0-rc.2.23426.4</SystemTextJsonVersion>
29-
<MicrosoftNETCoreAppRefVersion>8.0.0-rc.2.23426.4</MicrosoftNETCoreAppRefVersion>
30-
<MicrosoftNETCoreAppRuntimewinx64Version>8.0.0-rc.2.23426.4</MicrosoftNETCoreAppRuntimewinx64Version>
31-
<MicrosoftNETCoreBrowserDebugHostTransportVersion>8.0.0-rc.2.23426.4</MicrosoftNETCoreBrowserDebugHostTransportVersion>
19+
<MicrosoftExtensionsCachingMemoryVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsCachingMemoryVersion>
20+
<MicrosoftExtensionsConfigurationVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsConfigurationVersion>
21+
<MicrosoftExtensionsConfigurationAbstractionsVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsConfigurationAbstractionsVersion>
22+
<MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>
23+
<MicrosoftExtensionsConfigurationJsonVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsConfigurationJsonVersion>
24+
<MicrosoftExtensionsDependencyInjectionVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsDependencyInjectionVersion>
25+
<MicrosoftExtensionsDependencyModelVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsDependencyModelVersion>
26+
<MicrosoftExtensionsHostFactoryResolverSourcesVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsHostFactoryResolverSourcesVersion>
27+
<MicrosoftExtensionsLoggingVersion>8.0.0-rc.2.23430.5</MicrosoftExtensionsLoggingVersion>
28+
<SystemTextJsonVersion>8.0.0-rc.2.23430.5</SystemTextJsonVersion>
29+
<MicrosoftNETCoreAppRefVersion>8.0.0-rc.2.23430.5</MicrosoftNETCoreAppRefVersion>
30+
<MicrosoftNETCoreAppRuntimewinx64Version>8.0.0-rc.2.23430.5</MicrosoftNETCoreAppRuntimewinx64Version>
31+
<MicrosoftNETCoreBrowserDebugHostTransportVersion>8.0.0-rc.2.23430.5</MicrosoftNETCoreBrowserDebugHostTransportVersion>
3232
</PropertyGroup>
3333
<PropertyGroup Label="Dependencies from dotnet/arcade">
3434
<MicrosoftDotNetBuildTasksTemplatingVersion>8.0.0-beta.23425.2</MicrosoftDotNetBuildTasksTemplatingVersion>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.EntityFrameworkCore.Design;
5+
6+
/// <summary>
7+
/// Design-time <see cref="MethodCallCodeFragment"/> extensions.
8+
/// </summary>
9+
public static class MethodCallCodeFragmentExtensions
10+
{
11+
/// <summary>
12+
/// Gets the using statements required for this method call.
13+
/// </summary>
14+
/// <param name="methodCall">The method call.</param>
15+
/// <returns>The usings.</returns>
16+
public static IEnumerable<string> GetRequiredUsings(this MethodCallCodeFragment methodCall)
17+
{
18+
var method = methodCall.MethodInfo;
19+
if (method?.IsStatic == true)
20+
{
21+
yield return method.DeclaringType!.Namespace!;
22+
}
23+
24+
foreach (var argument in methodCall.Arguments)
25+
{
26+
if (argument is NestedClosureCodeFragment nestedClosure)
27+
{
28+
foreach (var nestedUsing in nestedClosure.MethodCalls.SelectMany(GetRequiredUsings))
29+
{
30+
yield return nestedUsing;
31+
}
32+
}
33+
else if (argument is not null)
34+
{
35+
yield return argument.GetType().Namespace!;
36+
}
37+
}
38+
}
39+
}

src/EFCore.Design/Scaffolding/Internal/CSharpDbContextGenerator.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,11 @@ public virtual string TransformText()
101101

102102
}
103103

104+
var useProviderCall = providerCode.GenerateUseProvider(Options.ConnectionString);
105+
usings.AddRange(useProviderCall.GetRequiredUsings());
106+
104107
this.Write(" => optionsBuilder");
105-
this.Write(this.ToStringHelper.ToStringWithCulture(code.Fragment(providerCode.GenerateUseProvider(Options.ConnectionString), indent: 3)));
108+
this.Write(this.ToStringHelper.ToStringWithCulture(code.Fragment(useProviderCall, indent: 3)));
106109
this.Write(";\r\n\r\n");
107110

108111
}
@@ -617,7 +620,7 @@ public class CSharpDbContextGeneratorBase
617620
/// <summary>
618621
/// The string builder that generation-time code is using to assemble generated output
619622
/// </summary>
620-
protected System.Text.StringBuilder GenerationEnvironment
623+
public System.Text.StringBuilder GenerationEnvironment
621624
{
622625
get
623626
{

src/EFCore.Design/Scaffolding/Internal/CSharpDbContextGenerator.tt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ public partial class <#= Options.ContextName #> : DbContext
7878
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
7979
<#
8080
}
81+
82+
var useProviderCall = providerCode.GenerateUseProvider(Options.ConnectionString);
83+
usings.AddRange(useProviderCall.GetRequiredUsings());
8184
#>
82-
=> optionsBuilder<#= code.Fragment(providerCode.GenerateUseProvider(Options.ConnectionString), indent: 3) #>;
85+
=> optionsBuilder<#= code.Fragment(useProviderCall, indent: 3) #>;
8386

8487
<#
8588
}

src/EFCore.Relational/Query/Internal/RelationalProjectionBindingExpressionVisitor.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,17 @@ public virtual Expression Translate(SelectExpression selectExpression, Expressio
182182

183183
if (expression is MethodCallExpression methodCallExpression)
184184
{
185-
if (methodCallExpression.Method.IsGenericMethod
186-
&& methodCallExpression.Method.DeclaringType == typeof(Enumerable)
187-
&& methodCallExpression.Method.Name == nameof(Enumerable.ToList)
188-
&& methodCallExpression.Arguments.Count == 1
189-
&& methodCallExpression.Arguments[0].Type.TryGetElementType(typeof(IQueryable<>)) != null)
185+
if (methodCallExpression is
186+
{
187+
Method.IsGenericMethod: true,
188+
Method.Name: nameof(Enumerable.ToList),
189+
Method: var method,
190+
Arguments: [var argument]
191+
}
192+
&& method.DeclaringType == typeof(Enumerable)
193+
&& argument.Type.TryGetElementType(typeof(IQueryable<>)) != null)
190194
{
191-
var subquery = _queryableMethodTranslatingExpressionVisitor.TranslateSubquery(
192-
methodCallExpression.Arguments[0]);
193-
if (subquery != null)
195+
if (_queryableMethodTranslatingExpressionVisitor.TranslateSubquery(argument) is ShapedQueryExpression subquery)
194196
{
195197
_clientProjections!.Add(subquery);
196198
// expression.Type here will be List<T>

src/EFCore.Relational/Query/SqlExpressions/CrossApplyExpression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
3838
/// </summary>
3939
/// <param name="table">The <see cref="JoinExpressionBase.Table" /> property of the result.</param>
4040
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
41-
public virtual CrossApplyExpression Update(TableExpressionBase table)
41+
public override CrossApplyExpression Update(TableExpressionBase table)
4242
=> table != Table
4343
? new CrossApplyExpression(table, GetAnnotations())
4444
: this;

src/EFCore.Relational/Query/SqlExpressions/CrossJoinExpression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
3838
/// </summary>
3939
/// <param name="table">The <see cref="JoinExpressionBase.Table" /> property of the result.</param>
4040
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
41-
public virtual CrossJoinExpression Update(TableExpressionBase table)
41+
public override CrossJoinExpression Update(TableExpressionBase table)
4242
=> table != Table
4343
? new CrossJoinExpression(table, GetAnnotations())
4444
: this;

src/EFCore.Relational/Query/SqlExpressions/InnerJoinExpression.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,22 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
4848
/// <param name="table">The <see cref="JoinExpressionBase.Table" /> property of the result.</param>
4949
/// <param name="joinPredicate">The <see cref="PredicateJoinExpressionBase.JoinPredicate" /> property of the result.</param>
5050
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
51-
public virtual InnerJoinExpression Update(TableExpressionBase table, SqlExpression joinPredicate)
51+
public override InnerJoinExpression Update(TableExpressionBase table, SqlExpression joinPredicate)
5252
=> table != Table || joinPredicate != JoinPredicate
5353
? new InnerJoinExpression(table, joinPredicate, GetAnnotations())
5454
: this;
5555

56+
/// <summary>
57+
/// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will
58+
/// return this expression.
59+
/// </summary>
60+
/// <param name="table">The <see cref="JoinExpressionBase.Table" /> property of the result.</param>
61+
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
62+
public override InnerJoinExpression Update(TableExpressionBase table)
63+
=> table != Table
64+
? new InnerJoinExpression(table, JoinPredicate, GetAnnotations())
65+
: this;
66+
5667
/// <inheritdoc />
5768
protected override TableExpressionBase CreateWithAnnotations(IEnumerable<IAnnotation> annotations)
5869
=> new InnerJoinExpression(Table, JoinPredicate, annotations);

src/EFCore.Relational/Query/SqlExpressions/JoinExpressionBase.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ protected JoinExpressionBase(TableExpressionBase table, IEnumerable<IAnnotation>
3939
/// </summary>
4040
public virtual TableExpressionBase Table { get; }
4141

42+
/// <summary>
43+
/// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will
44+
/// return this expression.
45+
/// </summary>
46+
/// <param name="table">The <see cref="JoinExpressionBase.Table" /> property of the result.</param>
47+
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
48+
public abstract JoinExpressionBase Update(TableExpressionBase table);
49+
4250
/// <inheritdoc />
4351
public override bool Equals(object? obj)
4452
=> obj != null

0 commit comments

Comments
 (0)