| | | 1 | | using Elsa.KeyValues.Contracts; |
| | | 2 | | using Elsa.KeyValues.Entities; |
| | | 3 | | using Elsa.KeyValues.Models; |
| | | 4 | | using JetBrains.Annotations; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Persistence.EFCore.Modules.Runtime; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Entity Framework implementation of the <see cref="IKeyValueStore"/> |
| | | 10 | | /// </summary> |
| | | 11 | | [UsedImplicitly] |
| | 0 | 12 | | public class EFCoreKeyValueStore(Store<RuntimeElsaDbContext, SerializedKeyValuePair> store) : IKeyValueStore |
| | | 13 | | { |
| | | 14 | | /// <inheritdoc /> |
| | | 15 | | public Task SaveAsync(SerializedKeyValuePair keyValuePair, CancellationToken cancellationToken) |
| | | 16 | | { |
| | 0 | 17 | | return store.SaveAsync(keyValuePair, x => x.Id, cancellationToken); |
| | | 18 | | } |
| | | 19 | | |
| | | 20 | | /// <inheritdoc /> |
| | | 21 | | public Task<SerializedKeyValuePair?> FindAsync(KeyValueFilter filter, CancellationToken cancellationToken) |
| | | 22 | | { |
| | 0 | 23 | | return store.FindAsync(filter.Apply, cancellationToken); |
| | | 24 | | } |
| | | 25 | | |
| | | 26 | | /// <inheritdoc /> |
| | | 27 | | public Task<IEnumerable<SerializedKeyValuePair>> FindManyAsync(KeyValueFilter filter, CancellationToken cancellation |
| | | 28 | | { |
| | 0 | 29 | | return store.QueryAsync(filter.Apply, cancellationToken); |
| | | 30 | | } |
| | | 31 | | |
| | | 32 | | /// <inheritdoc /> |
| | | 33 | | public Task DeleteAsync(string key, CancellationToken cancellationToken) |
| | | 34 | | { |
| | 0 | 35 | | return store.DeleteWhereAsync(x => x.Id == key, cancellationToken); |
| | | 36 | | } |
| | | 37 | | } |