ardalis/Specification
소개
DDD 모델에 사양을 추가하기 위한 테스트가 포함된 기본 클래스
개발 도구측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- -1
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalAnnouncement!
Ardalis.Specification is moving to a commercial license. Tell me more
Give a Star! :star:
If you like or are using this project, please give it a star. Thanks!
Specification
A .NET library for building query specifications. Currently used in Microsoft reference application eShopOnWeb, which is the best place to see it in action, as well as the Clean Architecture solution template. Check out Steve "ardalis" Smith's associated (free!) eBook, Architecting Modern Web Applications with ASP.NET Core and Azure, as well.
Documentation
Read the Documentation
Releases
The change log for version 9 and the list of breaking changes can be found here.
Sample Usage
The Specification pattern pulls query-specific logic out of other places in the application where it currently exists.
- For applications with minimal abstraction that use EF Core directly, the specification will eliminate
Where,Include,Select, and similar expressions from almost all places where they're being used. - In applications that abstract database query logic behind a
Repositoryabstraction, the specification will typically eliminate the need for many customRepositoryimplementation classes as well as custom query methods onRepositoryimplementations. Instead of many different ways to filter and shape data using various methods, the same capability is achieved with a few core methods.
Example implementation in your repository using specifications
public async Task<List<T>> ListAsync(
ISpecification<T> specification,
CancellationToken cancellationToken = default)
{
var query = SpecificationEvaluator.Default
.GetQuery(_dbContext.Set<T>(), specification);
return await query.ToListAsync(cancellationToken);
}
Now, to use this method, the calling code simply instantiates and passes the appropriate specification.
var spec = new CustomerByNameSpec("customerName");
var customers = await _repository.ListAsync(spec, cancellationToken);
Specifications should be defined in an easily-discovered location in the application, so developers can easily reuse them. The use of this pattern helps to eliminate many commonly duplicated lambda expressions in applications, reducing bugs associated with this duplication.
We're shipping a built-in repository implementation RepositoryBase, ready to be consumed in your apps. You can use it as a reference and create your own custom repository implementation.
Reference
Please refer to the documentation for related resources.
Pluralsight resources:
관련 프로젝트 살펴보기
불러오는 중…