假设用户可以拥有一个文档集,每个集合可以有一个或多个文件。在UI上,我希望允许用户按照文件CreatedDate进行排序。因此,当用户单击列标题时,他们可以按日期进行排序(asc/desc)。考虑到以下情况,我如何配置这个排序行为HotChocolate端?
public class User
{
public List<DocSet> DocSets {get;set;}
}
public class DocSet
{
public List<File> Files {get;set}
public User User {get;set;}
}
public File
{
public string Name {get;set;}
public DocSet DocSet {get;set;}
public DateTime CreatedDate {get;set;}
}下面是HotChocolate查询,但不确定如何允许对文件CreatedDate属性进行排序(asc/desc)。
[UseDbContext]
[UseSorting]
public IQueryable<User> GetUser(
[ScopedService] MyDbContext dbContext
) => dbContext.Users;发布于 2022-04-09 17:00:30
试试这个:
public class DocSet
{
[UseSorting]
public List<File> Files {get;set}
public User User {get;set;}
}https://stackoverflow.com/questions/71801912
复制相似问题