Skip to content

Commit 60d048f

Browse files
author
SamuelRe
committed
add multitargeting for .net 8,9,10 and hide InterfaceSet behind IInterfaceSet to remove ambiguous invocation on .net 10
1 parent 1a846c9 commit 60d048f

8 files changed

Lines changed: 523 additions & 14 deletions

File tree

.gitignore

Lines changed: 480 additions & 7 deletions
Large diffs are not rendered by default.

EntityFrameworkCore.InterfaceSets.Tests/EntityFrameworkCore.InterfaceSets.Tests.csproj

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77

88
<IsPackable>false</IsPackable>
99
<IsTestProject>true</IsTestProject>
1010
</PropertyGroup>
1111

12+
<PropertyGroup Condition="'$(TargetFramework)' == 'net10.0'">
13+
<NoWarn>$(NoWarn);ASYNC0001</NoWarn>
14+
</PropertyGroup>
15+
1216
<ItemGroup>
1317
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
14-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.*" />
1518
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
1619
<PackageReference Include="NUnit" Version="3.14.0"/>
1720
<PackageReference Include="NUnit.Analyzers" Version="3.9.0"/>
1821
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
1922
</ItemGroup>
2023

24+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
25+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.*" />
26+
</ItemGroup>
27+
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
28+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.*" />
29+
</ItemGroup>
30+
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
31+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.*" />
32+
</ItemGroup>
33+
2134
<ItemGroup>
2235
<Using Include="NUnit.Framework"/>
36+
<Using Remove="System.Linq.AsyncEnumerable" Condition="'$(TargetFramework)' == 'net10.0'" />
2337
</ItemGroup>
2438
<ItemGroup>
2539
<ProjectReference Include="..\EntityFrameworkCore.InterfaceSets\EntityFrameworkCore.InterfaceSets.csproj" />

EntityFrameworkCore.InterfaceSets.sln.DotSettings.user

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADbSet_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003F4b21fc3f8a3abb5d25f06c622276fbec0fd3932f169cc6af520bf5abc6a46b4_003FDbSet_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
23
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEntityFrameworkQueryableExtensions_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fc69576b4a074ad2839225611609498e344b7e2819997af48dbb2d2f8257f3_003FEntityFrameworkQueryableExtensions_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
4+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEntityFrameworkRelationalServicesBuilder_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003F3b45ffd34d80de5fac30e7fb234d6f92d83a718371227a8929449c532311d6bf_003FEntityFrameworkRelationalServicesBuilder_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
35
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=152c6651_002De6de_002D4f17_002D96b2_002D30b1dd684217/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
46
&lt;Solution /&gt;&#xD;
57
&lt;/SessionState&gt;</s:String>

EntityFrameworkCore.InterfaceSets/DbContextExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static class DbContextExtensions
1313
/// <typeparam name="TInterface">The interface type that entities implement.</typeparam>
1414
/// <param name="context">The DbContext instance.</param>
1515
/// <returns>An InterfaceSet instance for querying entities through the interface.</returns>
16-
public static InterfaceSet<TInterface> InterfaceSet<TInterface>(this DbContext context)
16+
public static IInterfaceSet<TInterface> InterfaceSet<TInterface>(this DbContext context)
1717
where TInterface : class
1818
{
1919
if (context == null)

EntityFrameworkCore.InterfaceSets/EntityFrameworkCore.InterfaceSets.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77

@@ -24,9 +24,15 @@
2424
<NoWarn>$(NoWarn);1591</NoWarn>
2525
</PropertyGroup>
2626

27-
<ItemGroup>
27+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
2828
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.23" />
2929
</ItemGroup>
30+
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
31+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
32+
</ItemGroup>
33+
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
34+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.0" />
35+
</ItemGroup>
3036

3137
<ItemGroup>
3238
<None Include="../README.md" Pack="true" PackagePath="\" />
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace EntityFrameworkCore.InterfaceSets;
2+
3+
/// <summary>
4+
/// wrapper around multiple DbSets for entity types implementing <typeparamref name="TInterface"/> to allow querying via the interface.
5+
/// </summary>
6+
/// <typeparam name="TInterface"></typeparam>
7+
public interface IInterfaceSet<out TInterface> : IQueryable<TInterface>
8+
{
9+
public IAsyncEnumerable<TInterface> AsAsyncEnumerable() => (IAsyncEnumerable<TInterface>)this;
10+
11+
public IQueryable<TInterface> AsQueryable() => this;
12+
}

EntityFrameworkCore.InterfaceSets/InterfaceSet.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
namespace EntityFrameworkCore.InterfaceSets;
66

7-
public class InterfaceSet<TInterface> : InterfaceSetQueryable<TInterface,TInterface>,IEntityRootExpressionProvider
7+
public class InterfaceSet<TInterface> : InterfaceSetQueryable<TInterface,TInterface>,
8+
IInterfaceSet<TInterface>,
9+
IEntityRootExpressionProvider
810
where TInterface : class
911
{
1012
private readonly DbContext _context;

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.0",
3+
"version": "10.0.0",
44
"rollForward": "latestMinor",
55
"allowPrerelease": false
66
}

0 commit comments

Comments
 (0)