Skip to content

TResource type differing from IQueryable type. #794

Closed
@wasabii

Description

@wasabii

I am not using Entity Framework, since I do not want to couple my resource model to the underlying data model. As such, I am implementing a custom IResourceRepository<TResource>.

The IResourceRepository essentially allows you to compose up an IQueryable, applying filters, and sorts, to the underlying data source. Each method takes an IQueryable, and then returns an IQueryable. However: I do not intend to actually use this IQueryable as the final result. I would like the ToListAsync method to have a different return type.

The IQueryable can be used to compose up EF Core operations, like filters, or whatever, but then the final transformation of the data into a Resource should allow me to transform the IQueryable. Essentially, the IQueryable should not necessarily be the TResource type. I think it would make more sense if the interface was instead IResourceRepository<TResource, TQueryable>. That way each of the composition methods (Get, Include, etc) would shape the IQueryable, but the final ToListAsync method could transform that into the actual resource type.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions