-
Notifications
You must be signed in to change notification settings - Fork 133
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
System.InvalidOperationException: The LINQ expression could not be translated. #119
Comments
@marrrschine , Do you mind sharing Datamodel? |
which one do you mean specifically @maulik-modi? |
EF DataContext |
public class JobContext : DbContext
{
public JobContext(DbContextOptions<JobContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// Configure model relations
builder.ApplyConfiguration(new JobConfiguration());
}
public DbSet<Job> Jobs { get; set; }
} public class JobConfiguration : IEntityTypeConfiguration<Job>
{
public void Configure(EntityTypeBuilder<Job> builder)
{
builder
.Property(x => x.Id)
.ValueGeneratedOnAdd();
builder
.Property(x => x.Name)
.HasMaxLength(100);
builder
.Property(x => x.Status)
.HasConversion(
c => JsonConvert
.SerializeObject(c, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
}),
c => JsonConvert
.DeserializeObject<IList<Status>>(c, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
})
);
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey,
I'm not sure if it's a bug or I'm just boneheaded.
Anyway, when trying to sort a nested object by date, I run into the following exception:
The API controller method is pretty much like in the SieveTests (but returning new
JsonResult
instead ofJson
since a plain Web API controller should inherit fromControllerBase
and not fromController
)The respective API call is
curl -X GET "http://localhost:5500/api/Jobs?Sorts=sort_by_nested_property" -H "accept: text/plain"
Class
JobProcessor
added as scoped service inStartup.cs
Class
Job
Class
Status
Does anyone have an idea what is wrong here?
The text was updated successfully, but these errors were encountered: