views:

66

answers:

1

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?

+5  A: 

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.

womp