小编Meh*_*aki的帖子

无法隐式转换类型system.data.entity.infrastructure.DbRawSqlQuery <>.存在显式转换

我使用SqlQuery函数来运行存储过程.我的存储过程返回IEnumerable<String>.返回数据SqlQuery()是DbRawSqlQuery<IEnumerable<String>>.我该怎么把它转换成IEnumerable<String>?

.net c# sql

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

Cannot use KILL to kill your own process

I have SQL Server database which I want to delete using

DROP DATABASE <database-Name>
Run Code Online (Sandbox Code Playgroud)

But I receive this error:

Cannot drop database "Database-Name" because it is currently in use.

To solve the issue I called sp_who so I can see spid of the database which is in use.

Then I tried to kill it using :

KILL <spid>
Run Code Online (Sandbox Code Playgroud)

But I see this error: Cannot use KILL to kill your own process. I use SQL SERVER Management Studio to run the …

sql sql-server ssms

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

NET Core 3.0的JWT身份验证和Swagger

我正在使用.Net core 3.0开发一些Web Api,并希望将其与SwashBuckle.Swagger集成。它工作正常,但是当我添加JWT身份验证时,它无法按我预期的那样工作。为此,我添加了以下代码:

  services.AddSwaggerGen(c =>
        {
            c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "My Web API", Version = "v1" });
            c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
            {
                Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
                Name = "Authorization",
                In = ParameterLocation.Header,
                Type = SecuritySchemeType.ApiKey
            });

        });
Run Code Online (Sandbox Code Playgroud)

添加AddSecurityDefinition功能后,我可以看到“授权”按钮,当我单击它时,会看到以下表单: 在此处输入图片说明

然后输入Bearer WhatEverApiKeyIsfgdgdgdg845734987fgdhgiher635kjh,完成后authorization: Bearer WhatEverApiKeyIsfgdgdgdg845734987fgdhgiher635kjh,当我从Swagger向Web Api发送请求时,我希望在请求的标头中看到该内容。但是授权未添加到请求标头中。我正在使用SwashBuckle.Swagger(5.0.0-rc3)。请注意,有许多示例可以在.net core 2.0上正常运行,但是Swashbuckle摇摇欲坠的功能在最新版本上已更改,因此我无法使用该示例。

swagger swashbuckle asp.net-core-webapi .net-core-3.0

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

Angular:在使用 HttpClient、Observable 和异步管道加载 http 数据时执行工作

我在 angular 6 应用程序中使用 HttpClient 来加载数据。成功加载数据后,我需要做一些额外的工作。如果我使用 subscribe 功能,我可以很容易地在 subscribe 中做到这一点,例如:

http.get("/addressOfService").subscribe(data=>{
   this.info =data;
   DoJob();
});
Run Code Online (Sandbox Code Playgroud)

但我知道加载数据并在视图中使用它的最佳实践是尽可能长时间地使用异步管道,所以我正在使用它。现在我的问题是在加载数据并且用户使用异步管道时运行函数的最佳实践是什么。我尝试了一些不同的解决方案,发现我可以使用 map 函数,例如:

http.get("/addressOfService").pipe(map(data=>{
   DoJob();
   return data;
}));
Run Code Online (Sandbox Code Playgroud)

但我不确定这是否是一个好习惯。

observable rxjs angular angular6

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