Fikre
Fikre

Reputation: 565

Where in a domain model is it best to keep a reference to the current user?

How should the current user be passed to the repository classes?

The current user's credentials are needed for the connection string used by the repositories. Should each repository be instantiated by having the username and password passed as constructor parameters? That would mean that each domain object having a repository should be aware of the current user.

Where in my domain model is it best to keep a reference to the current user?

Upvotes: 4

Views: 305

Answers (1)

womp
womp

Reputation: 116987

Given your description, I would tend to scope the current user to some sort of "ApplicationContext" object. This would be analogous to HttpContext/Session for ASP.Net or some kind of Singleton instance in a forms application.

Upvotes: 6

Related Questions