这是我的实体。我首先使用实体框架代码。
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; }
}
在我的控制器中,我有:
[AcceptVerbs("PATCH")]
public void UpdateTrade(Guid id, Delta<Trade> update)
{
var tradeToUpdate = _repTradeService.GetRepTradeById(id);
update.Patch(tradeToUpdate);
_repTradeService.SaveChanges();
}
当我发出请求(使用提琴手)时,更新为空。这是补丁请求:
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"}
补丁操作中“更新”的值始终为空。任何指向为什么?