Skip to content

There is no good way to filter by the parent with isnull or isnotnull operators #548

Closed
@sk-pub

Description

@sk-pub

Description

There is no good way to filter by the parent with isnull or isnotnull operators.

If I have a class Child referencing the Parent, both use int as a Key, then I cannot use a filter query like this
api/children?filter[parent.id]=isnull:
— it fails to create the equality expression (because you can't compare int and null).

There are 2 bad workarounds for this right now:

  1. Add the [Attr] attribute to the Parent property of the Child and use the following filter instead
    api/children?filter[parent]=isnull:
    It causes the loading of the whole Parent hierarchy into attributes.
  2. Change the Key type from int to Nullable. It's nonsense to have a nullable primary key.

Environment

  • JsonApiDotNetCore Version: the current master branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions