tags:

views:

152

answers:

1

Where in the solution/projects, should I put the models for the data access layer. For example, if I have a login module that needs to use a Users table in a database, and I have a User.cs model. Where would that file go. If other modules need to be able to access this User.cs for information, then I cannot put it in the module. But then I fail to see how this can remain loosely coupled.

+1  A: 

For the loose coupling, you'd typically store an interface for these objects in a seperate assembly for all of the other projects to refer to. At my company we call this a "Contracts" assembly and it generally contains only interfaces or simple types.

As for where the model should go, if you keep your interfaces in a seperate DLL for all to use, you can put your model wherever you want. Generally I consider either my WCF contracts or my ORM (like Linq2Sql, etc) types to be my model and I store them wherever I usually store those kinds of things. The "model" I consider to be a bit more fluid... wherever feels good.

I'm more rigid about Views and ViewModels being in namespaces ending with "Views" and "ViewModels"

Hope this helps.

Anderson Imes