Skip to content

ProjectToType with NpgSql JSONB data type #1

Open
@gaiver

Description

@gaiver

Query fails with exception when used ProjectToType with entity having child class in JSONB format (EF.Core 7):

"The LINQ expression 'namelessParameter{0} => new Dto{ Number = namelessParameter{0}.Number, Date = namelessParameter{0}.Date, Amount = namelessParameter{0}.Amount' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'.

EF.Core without using ProjectToType translates it corerctly.

`
public class Entity
{
public string Id { get; set; }
public string Name { get; set; }
public Info[] Info
}

public class Info
{
public string Number { get; set; }
public DateOnly Date { get; set; }
public decimal Amount { get; set; }
}

public class EntityConfiguration : IEntityTypeConfiguration
{
public void Configure(EntityTypeBuilder builder)
{
builder.HasKey(u => u.Id);
builder.Property(p => p.Info)
.HasColumnType("jsonb");
}
}
`

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