Closed elyosemite closed 10 months ago
Hi @elyosemite,
That's way too opinionated. Forcing everyone to apply IEntity
to all entities will piss off everyone.
This library is agnostic to how you organize your codebase, or what architectural decisions you've made. That's up to you as a consumer. You may not even be using repositories, and that's fine; use specifications without repositories.
Yes, the specifications play nicely with repositories. And if you choose to do so, then please check our samples (in the sample folder in this repo). In Sample3 we have an example implementation using read and write repositories; where the write repository is constrained to only aggregate roots (entities marked with IAggregateRoot
).
Awesome!!! Thanks for the observations. <3
In a Domain-Driven Design approach, we have aggregates and entities, so it is common to see markup interfaces such as IAggregateRoot and IEntity.
That being said, it wouldn't be interesting to think about Specification applied to an entity, so you've already considered - in the Ardalis.Specification nuget - using it in the following way:
public interface ISpecification<T> where T : IEntity.
And the second solution would be for repositories, in which it would only allow using IAggregateRoot.
public interface IReadRepositoryBase<T> where T : IAggregateRoot.