小编Har*_*rry的帖子

concatLatestFrom 带有多个选择器 ngrx

我正在尝试使用 NgRx 12 中引入的最新 concatLatestFrom 获取 2 个选择器,但是我似乎无法理解我做错了什么,并且我无法实现这一点。

\n

我有一个看起来像这样的效果

\n
  loadAllCases$ = createEffect(() => this._actions$.pipe(\n    concatLatestFrom(() => [\n      this.store.pipe(select(CaseSelectors.getAllCases)),\n      this.store.pipe(select(CaseSelectors.getCasesLoaded))\n    ]),\n    navigation(this.caseLandingPage, {\n      run: (snap, [loaded, cases]) => {\n        if (loaded) {\n          return CaseActions.loadAllSuccess();\n        } else {\n          return this._caseService.getAll().pipe(\n            map(cases => CaseActions.loadAllSuccess(cases))\n          );\n        }\n      },\n      onError: (action, error) => {\n        return CaseActions.loadAllFailed(error);\n      }\n    })\n  ));\n\n
Run Code Online (Sandbox Code Playgroud)\n

然而,由于类型不兼容,这似乎不起作用

\n
Argument of type \'OperatorFunction<Action, [Action, boolean, Case[]]>\' is not assignable to \nparameter of type \'OperatorFunction<Action, ActionOrActionWithState<unknown, Action>>\'. \nType \'[Action, boolean, Case[]]\' …
Run Code Online (Sandbox Code Playgroud)

ngrx ngrx-effects angular ngrx-store nrwl-nx

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

多个可选参数 web api 属性路由

我是属性路由的新手,我不确定这是否可能。

我有一个属性路由,它可以像这样正常工作:

[HttpGet]
[Route("GetIssuesByFlag/{flag:int=3}")]
public IEnumerable<IssueDto> GetIssuesByFlag(int flag)
Run Code Online (Sandbox Code Playgroud)

现在我想添加一些额外的可选参数来缩小我的搜索范围,所以我想添加 2 个额外的可选参数。

我尝试过的:

[HttpGet]
[Route("GetIssuesByFlag/{flag:int=3?}/{categoryId:int?}/{tagIds?}")]
public IEnumerable<IssueDto> GetIssuesByFlag(int flag , int? categoryId = null, int?[] tagIds = null)
Run Code Online (Sandbox Code Playgroud)

如果我的电话是/api/controller/1/2,这可以正常工作,但在/api/controller/1.

我怎样才能做到这一点?

编辑 1:下面 Nkosi 的回答有效,但是需要额外的修改。

[HttpGet]
[Route("GetIssuesByFlag/{flag:int=3}/{tagIds?}/{categoryId:int?}")]
public IEnumerable<IssueDto> GetIssuesByFlag(int flag , List<int> tagIds, int? categoryId = null )
Run Code Online (Sandbox Code Playgroud)

列表或数组必须是第二个,因为如果没有提供值,它会自动为空,并且不能用 = null 标记为可选。

c# asp.net asp.net-web-api attributerouting asp.net-web-api-routing

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

Visual Studio团队服务部署/构建证书错误

我正在尝试使用VSTS中的持续集成和部署功能构建一次性点击应用程序(Visual Studio团队服务在线)我们正在尝试使用Hosted代理构建这个Visual Studio 2015我们在使用一个强名称密钥文件签名时遇到了困难的错误

MSB3326: Cannot import the following key file: xxxx.snk. The key file may be password protected. To correct this, try to import the certificate again or import the certificate manually into the current user's personal certificate store. 在那之后

MSB3321: Importing key file "xxxx.pfx" was canceled.

我试图从商店和文件中选择更改位置并确保提交但没有成功.任何想法我如何克服这些错误或做错了什么.

选择答案的Clerification

只是想澄清是否有其他人有同样的问题,除了答案我必须将我的证书放在我的源代码控制代码中并提交它.然后选择其位置在VSTS Build上添加一个全局变量

在此输入图像描述

$cert.Import("$(CertPath)", $password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]"PersistKeySet") 其中$(CertPath)就像是 $(Build.SourcesDirectory)\SharedSolutionFiles\CertificateName.pfx

azure-devops azure-pipelines-build-task azure-pipelines

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

在 Azure 搜索中,如何将日期时间字段与日期时间文字进行比较?

因此,我尝试使用 Azure 搜索对我的表存储进行查询,该表已编入索引。在此处查看表的实体

   [SerializePropertyNamesAsCamelCase]
public class Asset : TableEntity
{
    public Asset(){ }

    public Asset(string name, DateTimeOffset toBePublished)
    {
        Name = name;
        ToBePublishedDate = toBePublished.ToString();
    }

    [System.ComponentModel.DataAnnotations.Key]
    public string Id{ get; set; } = DateTimeOffset.UtcNow.ToString();

    [IsFilterable, IsSortable, IsSearchable]
    public string Name { get; set; }

    [IsFilterable, IsSortable, IsSearchable]
    public string Version { get; set; }

    [IsFilterable, IsSortable, IsSearchable]
    public string ToBePublishedDate { get; set; }

    [IsFilterable, IsSortable, IsSearchable]
    public string ToBeRetiredDate { get; set; }

    [IsFilterable, IsSortable]
    public bool IsApproved …
Run Code Online (Sandbox Code Playgroud)

c# azure azure-cognitive-search

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

Angular Post json到.net核心web api为空

我试图将一些JSON发布到web api .net核心但由于某种原因,无论我尝试过什么,都会看到下面的代码.

这是我的.net核心web api代码

    [Produces("application/json")]
    [Route("api/v1/Issues")]
    [Authorize]
    [EnableCors("AllowCors")]
    public class IssuesController : Controller
    {
        [HttpPost]
        public IActionResult PostIssues([FromBody] string issue)
        {
          //some code to desirialize
        }
    }
Run Code Online (Sandbox Code Playgroud)

这就是我试图通过角度发布的方式(注意加载了相应的服务)

    public addIssue(issue) {
    const headers = new Headers();
    this.authService.getToken().toPromise().then( t => {
      headers.append('Authorization', `Bearer ${t.toString()}`);
      headers.append('Content-Type', 'application/json')
      this.http.post(`${this.baseUrl}/v1/issues`, issue, {
        headers: headers
      }).toPromise()
        .then(res => {
          console.log(res.json());
        });
    });
  }
Run Code Online (Sandbox Code Playgroud)

我试过把帖子改成了

this.http.post(`${this.baseUrl}/v1/issues`, JSON.stringify(issue))
Run Code Online (Sandbox Code Playgroud)

乃至

this.http.post(`${this.baseUrl}/v1/issues`, {'issue', JSON.stringify(issue)})
Run Code Online (Sandbox Code Playgroud)

但似乎没有任何工作,任何人都知道为什么会发生这种情况?澄清string issueAPI上收到的内容始终为null.这是成功的响应,当我到达服务器时,您可以看到请求有效负载不为null但是到达web api为null 在此输入图像描述

更新1如果可能需要说明 好吧我想做一个小实验,相同的代码适用于4.5框架而不是.net核心但是我试图为.net核心和工作做的是创建一个名为foo的类,见下文

public class Foo
    {
        public string Name …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core asp.net-core-webapi angular

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

无法将动态表实体强制转换为自定义实体Azure表存储

我试图基于分区键替换我的表上的实体和行键成功检索实体但当我尝试强制转换它时,它会抛出一个无效的强制转换异常.我查看了MSDN文档,这是正确的删除方法,甚至确保遵循创建实体的准则

您要存储在表中的实体属性必须是该类型的公共属性,并支持获取和设置值.此外,您的实体类型必须公开无参数构造函数

这是我的班级

    public class BasicAsset : TableEntity
{
    public BasicAsset()
    {
    }

    public BasicAsset(string name)
    {
        Name = name;
    }


    [IsFilterable, IsSortable, IsSearchable]
    public string Name { get; set; }

    [IsFilterable, IsSortable]
    public int Version { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

这是我在异常时的代码

TableOperation retreiveOperation = TableOperation.Retrieve("Orginization", result.Results[0].Document.RowKey);
TableResult toDelete = await table.ExecuteAsync(retreiveOperation);
BasicAsset toReplaceAsset = (BasicAsset) toDelete.Result;
//Change what is new here
toReplaceAsset.Version = asset.Version;
TableOperation replaceOperation = TableOperation.Replace(toReplaceAsset);
Run Code Online (Sandbox Code Playgroud)

错误

   e = {System.InvalidCastException: Unable to cast object of type 'Microsoft.WindowsAzure.Storage.Table.DynamicTableEntity' …
Run Code Online (Sandbox Code Playgroud)

c# azure azure-table-storage

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