Skip to content

Filter expression translation #788

Closed
@ClintGood

Description

@ClintGood

Attempting to use JsonApiDotNetCore with SQL Server backend.
Receiving all "Teams" works fine.
Attempting to get single "Team" entity with GUID Id field.
Error received:
The LINQ expression 'DbSet
.Where(t => t.Id.Equals((object)__id_0))' could not be translated.
So the filter expression is casting to an object and this cannot be understood by the SQL server ef provider.

I figured that it was because the expression allowed for __id to be nullable, so I added a generic constraint to TId so that is was a non nullable value type (where TId: struct)
This did not make any difference.

Is this a bug with how the expression is being constructed or am I missing something.

public class Team: Identifiable<Guid>
{

    [Key]
    [Column("TeamId")]
    public override Guid Id { get; set; }

    [MaxLength(255)]
    [Required]
    [Attr]
    public string TeamName { get; set; }

    [HasMany]
    public List<TeamPlayer> TeamPlayers { get; set; }
}

...

Environment

  • JsonApiDotNetCore Version: latest master
  • Other Relevant Package Versions: ef 3.1.5

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