ASP.NET BoilerPlate:如何在应用程序服务中注入DbContext对象? [英] ASP.NET BoilerPlate: How do I inject object of DbContext in application service?
本文介绍了ASP.NET BoilerPlate:如何在应用程序服务中注入DbContext对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在应用程序服务中注入DbContext对象?
How do I inject object of DbContext in application service?
需要访问它以创建实体记录的克隆.
Need to access it to create clone of a entity record.
推荐答案
您可以将IDbContextProvider<TDbContext> _sampleDbContextProvider
用作构造函数注入,并与_sampleDbContextProvider.GetDbContext();
You can use IDbContextProvider<TDbContext> _sampleDbContextProvider
as constructor injection, using with _sampleDbContextProvider.GetDbContext();
这篇关于ASP.NET BoilerPlate:如何在应用程序服务中注入DbContext对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文