在複雜類型內部添加關係時出現跟隨錯誤。我該如何解決這個問題。我大吃一驚,認爲這是OData V3的問題,而不是OData V4的問題。WebAPI和Odata V4問題:包含實體的ComplexType
複雜類型'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() at c:\ OneIM \ EngSys \ One中的Microsoft.OneIM.ActiveIncident.Service.ModelBuilder.BuildIncidentModels() IM \ ActiveIncident \ src \ Product \ Service \ Models \ ModelBuilder.cs:line 42 at Microsoft.OneIM.ActiveIncident.Service.WebApiConfig.Register(HttpConfiguration config)in c:\ OneIM \ EngSys \ OneIM \ ActiveIncident \ src \ Product \ Service \ App_Start \ WebApiConfig.cs:line 22 at c:\ OneIM \ EngSys \ OneIM \ ActiveIncident \ src \ Product \ ServiceHost \ ApiStartup.cs中的Microsoft.OneIM.ActiveIncident.ServiceHost.ApiStartup.Configuration(IAppBuilder appBuilder)線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; }
}
這沒有奏效,並給了相同的錯誤 – sammym 2015-02-24 20:19:54