-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for enhanced filtering for document-based repo
We now need a new document-based specific interface since it will have a new method (EnumerateAsync) which is exclusive for documents. So we rename the old interfaces to `ITableStorage` and `ITableStoragePartition`, which now become the base interfaces for both, and introduce the new `IDocumentRepository` and `IDocumentPartition` which basically add the new enumeration with a filtering expression. The implementation for documents relies on the underlying `TableQuery`, since we are persisting actual `TableEntity` objects and therefore don't need any of the shenanigans from our POCO repos. Fixes #37
- Loading branch information
Showing
20 changed files
with
273 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//<auto-generated/> | ||
#nullable enable | ||
using Microsoft.Azure.Cosmos.Table; | ||
|
||
namespace Devlooped | ||
{ | ||
/// <summary> | ||
/// Document metadata for <see cref="IDocumentRepository{T}"/> querying purposes. | ||
/// </summary> | ||
partial interface IDocumentEntity : ITableEntity | ||
{ | ||
/// <summary> | ||
/// The type of the document, its <see cref="System.Type.FullName"/>. | ||
/// </summary> | ||
string? Type { get; } | ||
|
||
/// <summary> | ||
/// The major.minor version of the assembly the document type belongs to. | ||
/// </summary> | ||
string? Version { get; } | ||
|
||
/// <summary> | ||
/// The major component of the <see cref="Version"/>. | ||
/// </summary> | ||
int? MajorVersion { get; } | ||
|
||
/// <summary> | ||
/// The minor component of the <see cref="Version"/>. | ||
/// </summary> | ||
int? MinorVersion { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//<auto-generated/> | ||
#nullable enable | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq.Expressions; | ||
using System.Threading; | ||
|
||
namespace Devlooped | ||
{ | ||
/// <summary> | ||
/// A specific partition within an <see cref="IDocumentRepository{T}"/>. | ||
/// </summary> | ||
/// <typeparam name="T">The type of entity being persisted.</typeparam> | ||
partial interface IDocumentPartition<T> : ITableStoragePartition<T> where T : class | ||
{ | ||
/// <summary> | ||
/// Queries the document repository for items that match the given <paramref name="predicate"/>. | ||
/// </summary> | ||
/// <example> | ||
/// var books = DocumentPartition.Create<Book>(); | ||
/// await foreach (var book in books.EnumerateAsync(x => | ||
/// x.PartitionKey == "Rick Riordan" && | ||
/// x.RowKey.CompareTo("Percy Jackson") >= 0 && | ||
/// x.Version == "1.0")) | ||
/// { | ||
/// Console.WriteLine(book.ISBN); | ||
/// } | ||
/// </example> | ||
public IAsyncEnumerable<T> EnumerateAsync(Expression<Func<IDocumentEntity, bool>> predicate, CancellationToken cancellation = default); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//<auto-generated/> | ||
#nullable enable | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq.Expressions; | ||
using System.Threading; | ||
|
||
namespace Devlooped | ||
{ | ||
/// <summary> | ||
/// A generic repository that stores entities in table storage as serialized | ||
/// documents. | ||
/// </summary> | ||
/// <typeparam name="T">The type of entity being persisted.</typeparam> | ||
partial interface IDocumentRepository<T> : ITableStorage<T> where T : class | ||
{ | ||
/// <summary> | ||
/// Queries the document repository for items that match the given <paramref name="predicate"/>. | ||
/// </summary> | ||
/// <example> | ||
/// var books = DocumentRepository.Create<Book>(); | ||
/// await foreach (var book in books.EnumerateAsync(x => x.PartitionKey == "Rick Riordan" && x.DocumentType )) | ||
/// { | ||
/// Console.WriteLine(book.ISBN); | ||
/// } | ||
/// </example> | ||
public IAsyncEnumerable<T> EnumerateAsync(Expression<Func<IDocumentEntity, bool>> predicate, CancellationToken cancellation = default); | ||
} | ||
} |
Oops, something went wrong.