Skip to content
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

ProjectToType with NpgSql JSONB data type #1

Open
gaiver opened this issue Jan 25, 2023 · 0 comments
Open

ProjectToType with NpgSql JSONB data type #1

gaiver opened this issue Jan 25, 2023 · 0 comments

Comments

@gaiver
Copy link

gaiver commented Jan 25, 2023

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");
}
}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant