gpt4 book ai didi

c# - 如何使用固定值对 linq 进行排序并使用另一种排序显示所有其余内容

转载 作者:行者123 更新时间:2023-11-30 16:45:18 26 4
gpt4 key购买 nike

<分区>

IQueryable<Employee> query = ((IEnumerable<Employee>)employeeList)
.Select(x => x)
.AsQueryable();

var strListEmployees = input.MustIncludeIdsInPage.Split(",").ToList();
//the list of employee is dynamic, it'd return 3, 4, 5 or more data

var entities = query
.OrderBy(item => strListEmployees.IndexOf(item.Id.ToString()))
.PageBy(input)
.ToList();

example data

我想要的是这样的顺序:按员工姓名

D
F
A
B
C
E
G
H

员工 D、F、A 排在最前面(在列表中固定值),其余的按姓名排序(排序依据)显示。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com