Browse Source

Remove the Enumerable.Contains() workaround from the Entity Framework Core stores

pull/2514/head
Kévin Chalet 2 months ago
parent
commit
03f8f3ff3c
  1. 9
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreResourceStore.cs
  2. 9
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs

9
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreResourceStore.cs

@ -174,11 +174,10 @@ public class OpenIddictEntityFrameworkCoreResourceStore<
{ {
var context = await Context.GetDbContextAsync(cancellationToken); var context = await Context.GetDbContextAsync(cancellationToken);
// Note: Enumerable.Contains() is deliberately used without the extension method syntax to ensure await foreach (var resource in (
// ImmutableArray.Contains() (which is not fully supported by Entity Framework Core) is not used instead. from resource in context.Set<TResource>().AsTracking()
await foreach (var resource in (from resource in context.Set<TResource>().AsTracking() where names.Contains(resource.Name!)
where Enumerable.Contains(names, resource.Name) select resource).AsAsyncEnumerable().WithCancellation(cancellationToken))
select resource).AsAsyncEnumerable().WithCancellation(cancellationToken))
{ {
yield return resource; yield return resource;
} }

9
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs

@ -174,11 +174,10 @@ public class OpenIddictEntityFrameworkCoreScopeStore<
{ {
var context = await Context.GetDbContextAsync(cancellationToken); var context = await Context.GetDbContextAsync(cancellationToken);
// Note: Enumerable.Contains() is deliberately used without the extension method syntax to ensure await foreach (var scope in (
// ImmutableArray.Contains() (which is not fully supported by Entity Framework Core) is not used instead. from scope in context.Set<TScope>().AsTracking()
await foreach (var scope in (from scope in context.Set<TScope>().AsTracking() where names.Contains(scope.Name!)
where Enumerable.Contains(names, scope.Name) select scope).AsAsyncEnumerable().WithCancellation(cancellationToken))
select scope).AsAsyncEnumerable().WithCancellation(cancellationToken))
{ {
yield return scope; yield return scope;
} }

Loading…
Cancel
Save