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

支援Pool 和 Factory #278

Open
ChengYen-Tang opened this issue Sep 22, 2024 · 6 comments
Open

支援Pool 和 Factory #278

ChengYen-Tang opened this issue Sep 22, 2024 · 6 comments

Comments

@ChengYen-Tang
Copy link

能不能支援Pool 和 Factory提升資源和連線效率
AddDbContextPool
AddDbContextFactory
AddPooledDbContextFactory

@xuejmnet
Copy link
Collaborator

@ChengYen-Tang 如果你可以找到重写dbcontext的reset重置方法那么是可以的,但是目前我没找到这个办法所以没办法支持,因为pool在使用后会调用reset将状态之类的重置我需要在这个时候将多余的分片dbcontext清理掉dispose掉但是目前没找到解决方案因为这个方法不是public或者protected的

@ChengYen-Tang
Copy link
Author

@xuejmnet
Copy link
Collaborator

@ChengYen-Tang 是的

@ChengYen-Tang
Copy link
Author

不過,我有一個疑問,如果要清理多餘的分片dbcontext,為什麼是實現在ResetState,而不是在dispose呢?

@xuejmnet
Copy link
Collaborator

@ChengYen-Tang 因为pool模式下是将dbcontext存到一个容器里面,然后调用租借返还两个方法将dbcontext给用户使用,而返还的时候会对其进行重置而不是dispose,因为dispose后将无法复用

@xuejmnet
Copy link
Collaborator

@ChengYen-Tang
https://www.cnblogs.com/CreateMyself/p/13945144.html
可以尝试看看这个博客

image

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

2 participants