Skip to content

Commit c15b970

Browse files
committed
Support both net6 and net7
1 parent 4fb6013 commit c15b970

7 files changed

Lines changed: 23 additions & 12 deletions

File tree

Directory.Build.props

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@
2323
</PropertyGroup>
2424

2525
<PropertyGroup>
26-
<TargetFrameworkVersion>net6.0</TargetFrameworkVersion>
26+
<TargetFrameworkVersion>net7.0;net6.0</TargetFrameworkVersion>
2727
<MicrosoftExtensionsVersion>6.0.0</MicrosoftExtensionsVersion>
2828
<EFCoreVersion>6.0.0</EFCoreVersion>
2929
<TestEFCoreVersion>$(EFCoreVersion)</TestEFCoreVersion>
3030
</PropertyGroup>
31-
31+
32+
<PropertyGroup Condition="'$(TargetFramework)' == 'net7.0'">
33+
<EFCoreVersion>7.0.0</EFCoreVersion>
34+
<TestEFCoreVersion>$(EFCoreVersion)</TestEFCoreVersion>
35+
</PropertyGroup>
3236

3337
</Project>

samples/BasicSample/BasicSample.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" />
14-
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
15-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
13+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0" />
14+
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
15+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
1616
</ItemGroup>
1717

1818
<ItemGroup>

samples/BasicSample/Program.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ public static void Main(string[] args)
159159

160160
result = dbContext.Users.FirstOrDefault(x => x.TotalSpent > 1);
161161
Console.WriteLine($"Our first user {result.FullName} has spent {result.TotalSpent}");
162+
163+
var spent = dbContext.Users.Sum(x => x.TotalSpent);
164+
Console.WriteLine($"Our users combined spent: {spent}");
162165
}
163166

164167
{

samples/ReadmeSample/ReadmeSample.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
14-
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
15-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
13+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />
14+
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
15+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
1616
</ItemGroup>
1717

1818
<ItemGroup>

src/EntityFrameworkCore.Projectables/EntityFrameworkCore.Projectables.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
55
<PackageReadmeFile>README.md</PackageReadmeFile>
66
</PropertyGroup>
77

src/EntityFrameworkCore.Projectables/Services/ProjectableExpressionReplacer.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ bool TryGetReflectedExpression(MemberInfo memberInfo, [NotNullWhen(true)] out La
128128
var self = _AddProjectableSelect(call.Arguments.First(), _entityType);
129129
return call.Update(null, call.Arguments.Skip(1).Prepend(self));
130130
}
131-
case QueryRootExpression root:
132-
return _AddProjectableSelect(root, root.EntityType);
131+
case QueryRootExpression root when _entityType != null:
132+
return _AddProjectableSelect(root, _entityType);
133133
default:
134134
return ret;
135135
}
@@ -214,7 +214,11 @@ PropertyInfo property when nodeExpression is not null
214214

215215
protected override Expression VisitExtension(Expression node)
216216
{
217+
#if NET7_0_OR_GREATER
218+
if (node is EntityQueryRootExpression root)
219+
#else
217220
if (node is QueryRootExpression root)
221+
#endif
218222
{
219223
_entityType = root.EntityType;
220224
}

tests/EntityFrameworkCore.Projectables.FunctionalTests/EntityFrameworkCore.Projectables.FunctionalTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="$(TestEFCoreVersion)" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.12" />
1212
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
1313
<PackageReference Include="ScenarioTests.XUnit" Version="1.0.0" />
1414
<PackageReference Include="Verify.Xunit" Version="11.5.0" />

0 commit comments

Comments
 (0)