gpt4 book ai didi

asp.net-web-api - 补丁的增量为空

转载 作者:行者123 更新时间:2023-12-04 02:47:44 28 4
gpt4 key购买 nike

这是我的实体。我首先使用实体​​框架代码。

public class Trade
{

public Guid Id { get; set; }
[MaxLength(10)]
public string AssetClass { get; set; }
public TradeBatch Batch { get; set; }
}

public class TradeBatch
{
public TradeBatch()
{
StartedOn = DateTime.Now;

}

public Guid Id { get; set; }

public DateTime StartedOn { get; set; }


public List<Trade> Trades { get; set; }
}

在我的 Controller 中我有:

[AcceptVerbs("PATCH")]
public void UpdateTrade(Guid id, Delta<Trade> update)
{
var tradeToUpdate = _repTradeService.GetRepTradeById(id);
update.Patch(tradeToUpdate);
_repTradeService.SaveChanges();
}

当我发出请求(使用 fiddler)时,更新为空。这是补丁请求:

PATCH http://localhost:61579/api/RepTrades/4e43b48a-a4fd-4ffc-841d-08dac55deb60 HTTP/1.0
User-Agent: Fiddler
Host: localhost:61579
Content-Length: 55

Content-Type: application/json
{"AssetClass":"Test"}

补丁操作中“更新”的值始终为空。有什么原因的指示吗?

最佳答案

您可能想尝试将内容类型 header 设置为 application/json;odata=verbose

我会刚刚发表评论,但还没有声誉。

关于asp.net-web-api - 补丁的增量为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18535042/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com