Share via

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
Developer technologies | .NET | Entity Framework Core
Windows for business | Windows Client for IT Pros | User experience | Other
Developer technologies | .NET | Other
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other

A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.

Developer technologies | C#
Developer technologies | 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.


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

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.