带odata的automapper是否支持多个orderby/?$orderby=Field1,Field2
.net core 2.2、automapper 9.0.0、efcore 2.2.6、odata 7.2.3 为了在上下文中使用自动映射,我使用AutoMapper.AspNetCore.OData.EFCore Version=1.0.0包带odata的automapper是否支持多个orderby/?$orderby=Field1,Field2,odata,automapper,ef-core-2.2,Odata,Automapper,Ef Core 2.2,.net core 2.2、automapper 9.0.0、efcore 2.2.6、odata 7.2.3 为了在上下文中使用自动映射,我使用AutoMapper.AspNetCore.OData.EFCore Version=1.0.0包 public class RolesController : ODataController { private readonly ApplicationDbContext _context; private readonly IMapp
public class RolesController : ODataController
{
private readonly ApplicationDbContext _context;
private readonly IMapper _mapper;
public RolesController(ApplicationDbContext context, IMapper mapper)
{
_context = context ?? throw new ArgumentNullException(nameof(context));
_mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
}
[EnableQuery]
public async Task<IActionResult> Get(ODataQueryOptions<RoleGridRow> options)
{
return Ok(await _context.Roles.AsNoTracking().GetQueryAsync(_mapper, options));
}
}
public RolesProfile()
{
CreateMap<ApplicationRole, RoleGridRow>()
.ForMember(dest => dest.Users, opt => opt.MapFrom(src => src.UserRoles ));
CreateMap<ApplicationUserRole, User>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.UserId))
.ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.User.Name));
}
automapper是否支持这一点?还是我忽略了什么?包中有一个bug。找到了,修好了。我将创建一个PR。发现一些关于分页/计数的其他错误 据报道,该公司也将为此创建公关。 EnableQuery现在也需要删除。在github上打开了一个问题:
public class RoleGridRow
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public bool IsActive { get; set; }
public List<User> Users { get; set; }
}
No generic method 'ThenBy' on type 'System.Linq.Queryable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.