private static void GetBulkInfrstructure <TEntity>(DbContext context, out IInfrastructure <IServiceProvider> sp, out IEntityType entity, out IRelationalConnection relationalConnection)
        {
            sp = (IInfrastructure <IServiceProvider>)context;
            var options = sp.GetService <IDbContextOptions>();

            entity = context.Model.FindEntityType(typeof(TEntity));

            if (entity == null)
            {
                throw new NotSupportedException($"The type {typeof(TEntity)} is not part of the EntityFramework metadata model. Only mapped entities are supported.");
            }

            relationalConnection = sp.GetService <IRelationalConnection>();
        }
Ejemplo n.º 2
0
 public static TService TryGetService <TService>([NotNull] this IInfrastructure <IServiceProvider> accessor)
 {
     try
     {
         return(accessor.GetService <TService>());
     }
     catch
     {
         return(default);
Ejemplo n.º 3
0
 public static StoreOptions zGetStoreOptions(this IInfrastructure <IServiceProvider> accessor)
 => accessor.GetService <IDbContextOptions>().Extensions
 .OfType <CoreOptionsExtension>().FirstOrDefault()?
 .ApplicationServiceProvider?.GetService <IOptions <IdentityOptions> >()?.Value?.Stores;