Skip to content

NullReference Nested resource include chains #433

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
Maan511 opened this issue Oct 17, 2018 · 1 comment
Closed

NullReference Nested resource include chains #433

Maan511 opened this issue Oct 17, 2018 · 1 comment
Labels

Comments

@Maan511
Copy link

Maan511 commented Oct 17, 2018

I found a bug when including nested reources. Consider the following example:

class Book {
  // This is optional
  [HasOne("Author")]
  public virtual Author Author { get; set; }
}

class Author {
  [HasMany("Image")]
  public virtual IList<Image> Images { get; set; }
}

class Image {
}

Now when requesting Books with ?Include="Author.Images" An exception is thrown from the ResourceGraph, when a book doesn't have an author. Because the parent entity is null.

public object GetRelationship<TParent>(TParent entity, string relationshipName)
{
var parentEntityType = entity.GetType();

@milosloub
Copy link
Contributor

I have the same issue

jaredcnance added a commit that referenced this issue Nov 13, 2018
Fix(#433): Nullable parent in nested inclusion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants