小编Bul*_*hsu的帖子

在测试 ASP.NET Core 应用程序时,如何使用 InMemory 数据库使用 EF Core 将数据播种到 DbContext?

您好,我的应用程序中包含一些集成测试。在实例化测试类时,我正在使用以下类准备数据库:

internal static class DatabaseTestPreparation
{
    private const string TestDatabaseName = "TestDatabase";

    internal static IServiceCollection ConfigureTestDatabases(this IServiceCollection services) =>
        services
            .PrepareTestDatabaseContext<EventStoreContext>()
            .PrepareTestDatabaseContext<GrantContext>();

    private static IServiceCollection PrepareTestDatabaseContext<T>(this IServiceCollection services)
        where T : DbContext
    {
        var descriptor = services.SingleOrDefault(service =>
            service.ServiceType == typeof(DbContextOptions<T>));

        if (!(descriptor is null))
        {
            services
                .Remove(descriptor);
        }

        services
            .AddDbContext<T>(options =>
                options.UseInMemoryDatabase(TestDatabaseName))
            .Seed<T>();

        return services;
    }

    private static IServiceCollection Seed<T>(this IServiceCollection services) where T : DbContext
    {
        var serviceProvider = services.BuildServiceProvider();
        
        var dbContext = serviceProvider
            .GetService(typeof(T)) as T;

        dbContext …
Run Code Online (Sandbox Code Playgroud)

c# asp.net integration-testing entity-framework-core asp.net-core

6
推荐指数
0
解决办法
2762
查看次数

如何在 vuetify 中的多个 v-select 中包装文本?

我有一个 v-select 组件,如下所示:

<v-select
  class="area-select"
  v-model="selectedAreas"
  multiple
  :items="areas"
  item-text="label"
  item-value="key"
  label="Select" />

...

.area-select {
  margin-left: 10px;
  margin-right: 10px;
  width: 280px;
}
Run Code Online (Sandbox Code Playgroud)

正如您所注意到的,它接受多个值。它还设置了一定的宽度。问题是,当我从这个组件中选择太多选项时,它会增加它的高度。我如何包装选择中显示的文本,而不是放大它?谢谢你的帮助。

javascript css vue.js vuetify.js

2
推荐指数
1
解决办法
1568
查看次数

如何在特定时间触发 .NET Core 3.1 托管服务?

我需要在特定时间触发托管服务,例如。每天13:00。我的典型 ExecuteAsync 方法似乎是这样的:

protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
     var interval = _configuration.IntervalInSeconds * 1000;

     while (!stoppingToken.IsCancellationRequested)
     { 
         // some job

         await Task
             .Delay(interval, stoppingToken);
     }
}
Run Code Online (Sandbox Code Playgroud)

例如,当应用程序启动时,会调用 executeAsync 方法,然后每分钟都会发生一些操作。现在我必须只在特定时间执行这样的操作。有什么方法可以实现这种行为吗?除了粗略计算下一次触发时间之外,我的问题还有什么解决方案吗??谢谢你的帮助。

c# .net-core asp.net-core asp.net-core-hosted-services

1
推荐指数
1
解决办法
1705
查看次数

如何更改 vuetify 复选框标签样式?

谁能解释一下如何将 css 设置为 vuetify 复选框?我想更改字体、大小等,但我不知道如何在样式部分访问它。这是我的复选框:

<v-checkbox
  class="type-box"
  dense
  v-for="type in feedTypeFilterList"
  :key="type.name"
  v-model="type.isSelected"
  :label="type.name"
/>
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助。

javascript css vue.js vuetify.js

1
推荐指数
1
解决办法
1万
查看次数