using Church.Net.DAL.EF; using Microsoft.Extensions.DependencyInjection; using WebAPI.Services; namespace WebAPI.Logics.Core { public class LogicService { private readonly IServiceScopeFactory serviceScopeFactory; public LogicService( //ChurchNetContext dbContext IServiceScopeFactory serviceScopeFactory ) { this.serviceScopeFactory = serviceScopeFactory; //DbContext = dbContext; } //public ChurchNetContext DbContext { get; } public string CurrentUserId { get { using (var scope = serviceScopeFactory.CreateScope()) { var service = scope.ServiceProvider.GetService(); return service.UserId; } } } } }