Skip to content

Fail to deserialize one end of HasOne Relationship 1↔(0-1)  #193

Closed
@jaredcnance

Description

@jaredcnance
class ModelA : Identifiable {
  [HasOne] ModelB ModelB { get; set; }
}
class ModelB : Identifiable {
  [HasOne] ModelA ModelA { get; set; }
  int ModelAId { get; set; }
}
JsonApiDotNetCore.Internal.JsonApiException : Failed to deserialize request body
---- JsonApiDotNetCore.Internal.JsonApiException : ModelA does not contain an relationsip named ModelB

var entityProperty = entityProperties.FirstOrDefault(p => p.Name == $"{attr.InternalRelationshipName}Id");
if (entityProperty == null)
throw new JsonApiException(400, $"{contextEntity.EntityType.Name} does not contain an relationsip named {attr.InternalRelationshipName}");

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions