EF Core, IOC delgate

PharmaSoft 1 Reputation point
2023-03-10T14:50:07.6133333+00:00
                services.AddTransient<Func<IUnitOfWork>>(implementationFactory: provider => new Func<IUnitOfWork>(IUnitOfWork () =>  {  return provider.GetService<IUnitOfWork>();  }  ));
Hello,
Could somebody develeloppe this funtion in multiple functions so I can try to anderstand ?
Thank you very much for your help
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
697 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,356 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,595 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,222 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,135 questions
{count} votes

1 answer

Sort by: Most helpful
  1. PharmaSoft 1 Reputation point
    2023-03-12T16:15:30.0966667+00:00

    Hello,

    Thank you for your help

    I found my answer like this

    var FUnit = new Func<IUnitOfWork>(target);
                    IUnitOfWork target()
                    {
                        return host.Services.GetService<IUnitOfWork>();
                    }
                    services.AddTransient<Func<IUnitOfWork>>((provider) => FUnit);
    
    0 comments No comments