I am trying to get the OData Query "orderby" on a nested property to work on .Net Core 3.1
According to my reading the correct query should be formatted like this:
https://{server}:{port}/v1/Entities?$expand=ownBy&$orderby=ownBy/userName
and I get the following error message:
System.InvalidOperationException: The LINQ expression 'DbSet<Entity>
.LeftJoin(
outer: DbSet<User>,
inner: p => EF.Property<Nullable<Guid>>(p, "OwnById"), outerKeySelector: u => EF.Property<Nullable<Guid>>(u, "UserId"),
innerKeySelector: (o, i) => new TransparentIdentifier<Portfolio, User>(
Outer = o,
Inner = i
))
.OrderBy(p => EF.Property<Nullable<Guid>>(p.Inner, "UserId") == null ? null : new UserModel{
UserEmail = p.Inner.UserEmail,
UserFirstName = p.Inner.UserFirstName,
UserId = p.Inner.UserId,
UserLastName = p.Inner.UserLastName,
Username = p.Inner.Username
}
.Username)' could not be translated.
There’s a NuGet package explicitly for OData and expression mapping, have you looked at that?
https://docs.automapper.org/en/stable/Expression-Translation-(UseAsDataSource).html
--
You received this message because you are subscribed to the Google Groups "AutoMapper-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to automapper-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/automapper-users/96ea9942-23c6-42bf-8065-47e057618785%40googlegroups.com.