ASP.NET MVC:有多少存储库? [英] ASP.NET MVC: How many repositories?
问题描述
我在这个过程中设计的ASP.NET MVC网站和我或许有点困惑,存储库的确切性质。
I am in the process is designing a website in ASP.NET MVC and am perhaps a little confused as to the exact nature of a repository.
继的NerdDinner例如,我的网站应该有一个资料库,供应了实体,因为我需要他们。不过,我也听说过,你应该有一个处理相关实体的具体套不同repositorys ....?
Following the NerdDinner example, my site should have one repository which serves up the entities as I need them. However, I have also heard that you should have different repositorys that deal with specific sets of related entities....?
在我的网站的情况下,会有一些实体(约15桌),但多数都是有关。它是确定/最好有一个包含所有我需要拉/更新/删除等或者我应该分割下来?的方法之一,库
In the case of my site, there will be a number of entities (around 15 tables) yet the majority are all related. Is it ok / advisable to have one repository that contains all the methods that I'll need for pulling / updating / deleting etc or should I split them down?
推荐答案
我为每个数据对象存储库。
I create a repository for each data object.
例如,一个简单的库数据库可包含以下信息库:
For example, a simple library database could contain the following repositories:
- AuthorRepository
- BookRepository
- PublisherRepository
这篇关于ASP.NET MVC:有多少存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!