ASP.NET BoilerPlate:如何在应用程序服务中注入 DbContext 对象? [英] ASP.NET BoilerPlate: How do I inject object of DbContext in application service?

查看:26
本文介绍了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_sampleDbContextProvider 作为构造函数注入,与 _sampleDbContextProvider.GetDbContext();

You can use IDbContextProvider<TDbContext> _sampleDbContextProvider as constructor injection, using with _sampleDbContextProvider.GetDbContext();

这篇关于ASP.NET BoilerPlate:如何在应用程序服务中注入 DbContext 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆