Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventStoreRepository GetById with Type at Runtime #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cbaxter
Copy link

@cbaxter cbaxter commented Jan 4, 2012

In order to better facilitate loading an IAggregate with a type at Runtime (without using reflection) I added two new methods to the EventStoreRepository as shown below.

public virtual IAggregate GetById(Type aggregateType, Guid id)
public virtual IAggregate GetById(Type aggregateType, Guid id, int versionToLoad)

In order to keep the IRepository interface clean, I chose to push the prior implementations of GetById below in to the RepositoryExtensions class. The downside to the latter change is that it is a breaking change for those who may have overriden the EventStoreRepository class to extend either of the origional GetById methods. Of course the latter change is not required, but I felt that it was the clean choice given that the generic type paramter was only used for typeof(TAggregate) inside the private GetAggregate method.

The parameter Type aggregateType is validated inside of private GetAggregate method to ensure the IAggregate interface has been implemented by the type and will throw an ArgumentException if missing.

* Converted IRepository interface to use Type parameter.
* Added IRepository extensions for GetById<TAggregate>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant