Skip to content

NullReference Nested resource include chains #433

Closed
@Maan511

Description

@Maan511

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();

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