Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jaredcnance opened this issue Nov 14, 2017 · 0 comments · Fixed by #194
Closed

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

jaredcnance opened this issue Nov 14, 2017 · 0 comments · Fixed by #194
Labels

Comments

@jaredcnance
Copy link
Contributor

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}");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

1 participant