Skip to content

When using document-based storage, allow projecting certain properties to columns #354

@kzu

Description

@kzu

This could be handy to allow querying by those columns in particular.

So maybe it could be via an implemented interface that's then used when creating the repository? For example: DocumentRepository.Create<Book, IAddressable>()?

        public static IDocumentRepository<T> Create<T, TProperties>(...)
            where T: class, TProperties
            where TProperties: IDocumentEntity

Where the returned document repository augmented IDocumentRepository<T> with the ability to perform queries, such as:

        public interface IDocumentRepository<T, TProperties> : IDocumentRepository<T>
            where T : class, TProperties
        {
            IAsyncEnumerable<T> CreateQuery(Expression<Func<TProperties, bool>> predicate, CancellationToken cancellation = default);
        }

Note that unlike table repository IQueryable<T> CreateQuery() version, we need to restrict the available properties for querying to the TProperties since not all T properties will be available as columns. So using an expression for the properties and an async enumerable with the full entity type seems the most natural.

Back this issue
Back this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions