IEvangelist / azure-cosmos-dotnet-repository

Wraps the .NET SDK for Azure Cosmos DB abstracting away the complexity, exposing a simple CRUD-based repository pattern
https://ievangelist.github.io/azure-cosmos-dotnet-repository
MIT License
301 stars 89 forks source link

Add support for the specification pattern in pageAsync #359

Open d1820 opened 11 months ago

d1820 commented 11 months ago

Is your feature request related to a problem? Please describe. There currently is no way to provide a complex expression easily (without writing and joining expression trees together to create an expression based on multiple query criteria, or to provide an orderBy that is almost always used in filtered paging scenarios. The specification pattern would allow for this.

Describe the solution you'd like Add an overload to the PageAsync to take in a specification

Describe alternatives you've considered Writing my own dynamic expression tree parser to join together an outer expression for dynamic search properties ( a search class where all non null properties need to be supplied)

mumby0168 commented 10 months ago

Hi @d1820 can you provide an example query you'd like to make? The specification pattern can be used along with paging, by deriving from a different specification base type. There is some examples here, and you can also extend these base classes to add extra functionality and use multiple .Where clauses. If this isn't what you meant feel free to share an example and I can try and assist:

https://github.com/IEvangelist/azure-cosmos-dotnet-repository/blob/7430997c2d62ce9f6e0c26f124ca16bc4cd5d56a/samples/Microsoft.Azure.CosmosRepository/Specification/SpecificationPagingSamples.cs#L18C5-L61C6

d1820 commented 9 months ago

thanks for the response. no I don't have a specific example after digging through the source code I saw how you are applying different types of specification patterns to the query method. I guess I was just looking at it from the perspective of if I'm calling pagingAsync having an explicit overload where I can pass in the specification pattern already tailored to that base type just makes it a lot cleaner and easier for the user to reason about usage. The online documentation barely scratches the surface on the specification pattern.

now that I see how the source code works it's not really that big a deal would be more of a convenience feature really.

This may have been sent with voice to text, so I apologize for any misspellings or incorrect wording

On Wed, Nov 8, 2023, 8:14 AM Billy Mumby @.***> wrote:

Hi @d1820 https://github.com/d1820 can you provide an example query you'd like to make? The specification pattern can be used along with paging, by deriving from a different specification base type. There is some examples here, and you can also extend these base classes to add extra functionality and use multiple .Where clauses. If this isn't what you meant feel free to share an example and I can try and assist:

https://github.com/IEvangelist/azure-cosmos-dotnet-repository/blob/7430997c2d62ce9f6e0c26f124ca16bc4cd5d56a/samples/Microsoft.Azure.CosmosRepository/Specification/SpecificationPagingSamples.cs#L18C5-L61C6

— Reply to this email directly, view it on GitHub https://github.com/IEvangelist/azure-cosmos-dotnet-repository/issues/359#issuecomment-1802091608, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAC4GH46EDTKDV3XCVTKRDDYDOOUFAVCNFSM6AAAAAA6SCXVSCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBSGA4TCNRQHA . You are receiving this because you were mentioned.Message ID: @.*** com>