Skip to content

Commit

Permalink
Support both net6 and net7
Browse files Browse the repository at this point in the history
  • Loading branch information
zoriya committed Oct 13, 2023
1 parent 4fb6013 commit c15b970
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
8 changes: 6 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworkVersion>net6.0</TargetFrameworkVersion>
<TargetFrameworkVersion>net7.0;net6.0</TargetFrameworkVersion>
<MicrosoftExtensionsVersion>6.0.0</MicrosoftExtensionsVersion>
<EFCoreVersion>6.0.0</EFCoreVersion>
<TestEFCoreVersion>$(EFCoreVersion)</TestEFCoreVersion>
</PropertyGroup>


<PropertyGroup Condition="'$(TargetFramework)' == 'net7.0'">
<EFCoreVersion>7.0.0</EFCoreVersion>
<TestEFCoreVersion>$(EFCoreVersion)</TestEFCoreVersion>
</PropertyGroup>

</Project>
6 changes: 3 additions & 3 deletions samples/BasicSample/BasicSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions samples/BasicSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ public static void Main(string[] args)

result = dbContext.Users.FirstOrDefault(x => x.TotalSpent > 1);
Console.WriteLine($"Our first user {result.FullName} has spent {result.TotalSpent}");

var spent = dbContext.Users.Sum(x => x.TotalSpent);
Console.WriteLine($"Our users combined spent: {spent}");
}

{
Expand Down
6 changes: 3 additions & 3 deletions samples/ReadmeSample/ReadmeSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ bool TryGetReflectedExpression(MemberInfo memberInfo, [NotNullWhen(true)] out La
var self = _AddProjectableSelect(call.Arguments.First(), _entityType);
return call.Update(null, call.Arguments.Skip(1).Prepend(self));
}
case QueryRootExpression root:
return _AddProjectableSelect(root, root.EntityType);
case QueryRootExpression root when _entityType != null:
return _AddProjectableSelect(root, _entityType);
default:
return ret;
}
Expand Down Expand Up @@ -214,7 +214,11 @@ PropertyInfo property when nodeExpression is not null

protected override Expression VisitExtension(Expression node)
{
#if NET7_0_OR_GREATER
if (node is EntityQueryRootExpression root)
#else
if (node is QueryRootExpression root)
#endif
{
_entityType = root.EntityType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="$(TestEFCoreVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.12" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="ScenarioTests.XUnit" Version="1.0.0" />
<PackageReference Include="Verify.Xunit" Version="11.5.0" />
Expand Down

0 comments on commit c15b970

Please sign in to comment.