【问题标题】:Order by string compared to string list与字符串列表相比按字符串排序
【发布时间】:2013-04-19 17:53:12
【问题描述】:

我正在尝试使用某种模式对一些数据进行排序,并且需要一些帮助来弄清楚如何这样做。我还没有看到在 orderby 子句中使用 linq 查询的任何示例,并且不确定如何在这种情况下对数据进行排序:

public IList<UserEventModel> GetListData(IDictionary<string, IList<string>> criteria, IEnumerable<UserEventModel> subscriptions)
{
    subscriptions = subscriptions.OrderBy(x => x.EntityType);
}

寻找附加到 EntityType 的扩展,以与键 [2] 处的“条件”值对的内容进行比较,例如x =&gt; x.EntityType.?(指定的值集合)

【问题讨论】:

标签: c# linq list linq-to-sql dictionary


【解决方案1】:

你几乎是对的。追加列表并尝试

 subscriptions = subscriptions
                   .OrderBy(x => x.EntityType).ToList();

【讨论】:

    猜你喜欢
    • 2021-07-07
    • 2020-07-17
    • 1970-01-01
    • 2021-06-10
    • 1970-01-01
    • 1970-01-01
    • 2018-07-02
    • 2018-05-20
    • 1970-01-01
    相关资源
    最近更新 更多