コード例 #1
0
        private void InitGroups()
        {
            List <KnxGroupWithStateDto> groups = null;

            using (var scope = _serviceProvider.CreateScope())
            {
                var ctx = scope.ServiceProvider.GetService <BBDomDbContext>();
                groups = ctx.KnxGroups
                         .Select(g => new KnxGroupWithStateDto
                {
                    Address = g.Address,
                    DPT     = g.DPT,
                    Name    = g.Name,
                    Read    = g.Read,
                    Write   = g.Write,
                })
                         .OrderBy(g => g.Address).ToList();
            }
            Groups = groups.ToDictionary(g => g.Address, g => g);
        }
コード例 #2
0
 /// <summary>
 /// Generate migrations before running this method, you can use these steps bellow:
 /// https://github.com/skoruba/IdentityServer4.Admin#ef-core--data-access
 /// </summary>
 /// <param name="host"></param>
 public static async Task EnsureSeedData <TIdentityServerDbContext, TIdentityDbContext, TPersistedGrantDbContext, TLogDbContext, TUser, TRole>(System.IServiceProvider sp)
     where TIdentityServerDbContext : DbContext, IAdminConfigurationDbContext
     where TIdentityDbContext : IdentityDbContextInt <UserProfile, ApplicationRole>
     where TPersistedGrantDbContext : DbContext, IAdminPersistedGrantDbContext
     where TLogDbContext : DbContext, IAdminLogDbContext
 {
     using (var serviceScope = sp.CreateScope())
     {
         var services = serviceScope.ServiceProvider;
         await EnsureDatabasesMigrated <TIdentityDbContext, TIdentityServerDbContext, TPersistedGrantDbContext, TLogDbContext>(services);
         await EnsureSeedData <TIdentityServerDbContext>(services);
     }
 }