C# 我想了解更多有关服务的信息。AddTransient<;Func<;DbConnection,IIntegrationEventLogService>&燃气轮机;()?

C# 我想了解更多有关服务的信息。AddTransient<;Func<;DbConnection,IIntegrationEventLogService>&燃气轮机;()?,c#,.net-core,C#,.net Core,我正在研究微软的eShopContainers项目。下面是一行,通过该行在启动时注入IIntegrationEventLogService: services.AddTransient<Func<DbConnection, IIntegrationEventLogService>>( sp => (DbConnection c) => new IntegrationEventLogService(c)); services.A

我正在研究微软的eShopContainers项目。下面是一行,通过该行在启动时注入
IIntegrationEventLogService

services.AddTransient<Func<DbConnection, IIntegrationEventLogService>>(
                sp => (DbConnection c) => new IntegrationEventLogService(c));
services.AddTransient(
sp=>(dbc连接=>新的IntegrationEventLogService(c));
您还可以在Github上看到整个类和项目


我想知道为什么要使用
(sp=>(DbConnection c)=>newintegrationeventlogservice(c))
和一些关于语法的声明

这回答了你的问题吗@不,那不是我的问题!我在瞬态和代码的其他部分询问func!我完全了解AddScope和AddTransient以及AddSingletone!我是说,那就更容易了。查看属于.NET的类Core@MindSwipe亲爱的朋友,我甚至知道Func!但我很难找到代码的用途!你知道的!我想知道为什么用这个复杂的类型而不是简单的类型?与AddTransient()类似,它添加了一个瞬态函数,调用该函数时将返回一个新的
integrationTeventlogService
,这是一个工厂函数。使用GitHub的搜索功能在显示用法的代码结果中搜索
Func
的用法