【发布时间】:2014-12-10 23:33:38
【问题描述】:
我有以下带注释的模型
public class TypeA
{
public int TypeAId { get; set; }
[Required]
public TypeB B { get; set; }
public string AValue { get; set; }
}
public class TypeB
{
public int TypeBId { get; set; }
public string BValue { get; set; }
}
由使用实体框架的 WCF 数据服务公开为 v3 odata。当我尝试使用 DataServiceContext 更新 TypeA 时,例如
var ctx = new Service.Context(new Uri("http://localhost/TestUpdateService/TestUpdateService.svc"));
var t = ctx.theATypes.Expand(p => p.B).First();
t.AValue = "New value";
ctx.UpdateObject(t);
ctx.SaveChanges();
我在服务中收到一个 DbEntityValidationException,说明“B 字段是必需的”
请求正文“MERGE /TestUpdateService/TestUpdateService.svc/theATypes(1) HTTP/1.1” 包含 AValue 属性更改,但不包含到属性 B 的任何链接信息(这是我对服务中验证失败的原因的猜测)。我是否遗漏了有关更新数据服务的内容?
【问题讨论】:
标签: .net odata wcf-data-services wcf-data-services-client