-
-
Notifications
You must be signed in to change notification settings - Fork 725
/
SchemaCache.cs
39 lines (36 loc) · 1.17 KB
/
SchemaCache.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Concurrent;
using HotChocolate.Execution;
using HotChocolate.Types;
using Microsoft.EntityFrameworkCore;
namespace HotChocolate.Data.Projections
{
public class SchemaCache
: ProjectionVisitorTestBase,
IDisposable
{
private readonly ConcurrentDictionary<(Type, object), IRequestExecutor> _cache =
new ConcurrentDictionary<(Type, object), IRequestExecutor>();
public IRequestExecutor CreateSchema<T>(
T[] entities,
Action<ModelBuilder>? onModelCreating = null,
bool usePaging = false,
bool useOffsetPaging = false,
ObjectType<T>? objectType = null)
where T : class
{
(Type, T[] entites) key = (typeof(T), entities);
return _cache.GetOrAdd(
key,
k => base.CreateSchema(
entities,
usePaging: usePaging,
useOffsetPaging: useOffsetPaging,
onModelCreating: onModelCreating,
objectType: objectType));
}
public void Dispose()
{
}
}
}