【发布时间】:2015-02-28 09:51:06
【问题描述】:
在复杂类型中添加关系时出现以下错误。我该如何解决这个问题。我大吃一惊,读到它是 OData V3 的问题,但不是 OData V4 的问题。
复杂类型“Microsoft.OneIM.ActiveIncident.Contracts.IncidentImpact”通过属性“ImpactedServices”引用实体类型“Microsoft.OneIM.ActiveIncident.Contracts.ImpactedService”。
在 System.Web.OData.Builder.ODataConventionModelBuilder.MapComplexType(ComplexTypeConfiguration complexType) 在 System.Web.OData.Builder.ODataConventionModelBuilder.MapType(StructuralTypeConfiguration edmType) 在 System.Web.OData.Builder.ODataConventionModelBuilder.AddComplexType(类型类型) 在 System.Web.OData.Builder.ODataConventionModelBuilder.ReconfigureEntityTypesAsComplexType(EntityTypeConfiguration[] misconfiguredEntityTypes) 在 System.Web.OData.Builder.ODataConventionModelBuilder.RediscoverComplexTypes() 在 System.Web.OData.Builder.ODataConventionModelBuilder.GetEdmModel() 在 Microsoft.OneIM.ActiveIncident.Service.ModelBuilder.BuildIncidentModels() 在 c:\OneIM\EngSys\OneIM\ActiveIncident\src\Product\Service\Models\ModelBuilder.cs:line 42 在 Microsoft.OneIM.ActiveIncident.Service.WebApiConfig.Register(HttpConfiguration config) 在 c:\OneIM\EngSys\OneIM\ActiveIncident\src\Product\Service\App_Start\WebApiConfig.cs:line 22 在 Microsoft.OneIM.ActiveIncident.ServiceHost.ApiStartup.Configuration(IAppBuilder appBuilder) 在 c:\OneIM\EngSys\OneIM\ActiveIncident\src\Product\ServiceHost\ApiStartup.cs:line 27
我的模型如下所示
public class Incident
{
public IncidentImpact Impact { get; set; }
}
[ComplexType]
public class IncidentImpact
{
public bool IsCustomerImpacting { get; set; }
public string SupportTicketId { get; set; }
public ICollection<ImpactedService> ImpactedServices { get; set; }
}
public class ImpactedService
{
public long Id { get; set; }
public long IncidentId { get; set; }
public Incident Incident { get; set; }
public long ServiceId { get; set; }
}
【问题讨论】:
标签: asp.net-web-api odata