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

持久化一般放在模块内部,还是放在主应用上? #16

Open
bxjg1987 opened this issue Nov 4, 2019 · 0 comments
Open

持久化一般放在模块内部,还是放在主应用上? #16

bxjg1987 opened this issue Nov 4, 2019 · 0 comments

Comments

@bxjg1987
Copy link

bxjg1987 commented Nov 4, 2019

大部分情况下我们需要的树形数据都很简单,所以我想在你的模块上提供一个默认实现(假如叫DefaultTree),关于持久化有两种想法

1、在模块内部实现持久化
在DefaultTree.Core中定义DefaultTreeEntity,实现IGeneralTree<TTree, TPrimaryKey>
在DefaultTree.EF中定义DBCotnext,其中定义DbSet
甚至继续提供应用服务TreeAppService、和一个通用的UI

2、模块中不处理持久化
在DefaultTree.Core中定义DefaultTreeEntity,实现IGeneralTree<TTree, TPrimaryKey>
在**主程序(也就是模块的使用方)**的DbContext去定义DbSet

前者这种方式如果我的系统有很多模块都涉及到持久化,那么我可能需要很多DbContext
后者这种方式感觉封装性不够强
请教下你有好的建议吗? 还是我哪想错了?

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

No branches or pull requests

1 participant