ardalis / ardalis/Specification

Add more materializing extension methods.

Open
#538 0 comments 1 reaction 1 assignee Claimed by @fiseni View on GitHub
enhancement
Dominant language
C#
Stars
2.3k
Forks
262
PR merge metrics
No merged PRs in 30d

Description

We expose the `WithSpecification` extension which applies the specification to any `IQueryable` source, [refer to the docs for more details](https://specification.ardalis.com/usage/use-specification-dbcontext.html).
We might go one step further and add some convenience extension methods covering some common use cases, e.g. `FirstOrDefaultAsync`, `SingleOrDefaultAsync`, etc. We already have such an extension `ToListAsync`, which is actually necessary considering the `PostProcessingAction`. But, we can expand to that and cover more methods.

### Example

Current usage:
```csharp
var customer = await dbContext.Customers
.WithSpecification(spec)
.FirstOrDefaultAsync(cancellationToken);
```

Proposed:
```csharp
var customer = await dbContext.Customers
.FirstOrDefaultAsync(spec, cancellationToken);
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.