小编Ada*_*ick的帖子

Linq按列表的顺序<int>给出的ID

我正在尝试对linq查询进行排序,以便按List [int]中找到的ID的顺序返回结果.这是我当前的代码返回它们很好,但没有排序.

IEnumerable<NPost> nposts;

List<int> npostIDs = (from tc in db.TopComs
                      where tc.Type == "Comments"
                      select tc.NPostID).ToList();

            nposts = from np in repository.NPosts
                     where npostIDs.Contains(np.NPostID)
                     select np;
Run Code Online (Sandbox Code Playgroud)

我怎样才能让nposts以List [int]中存在npostID的顺序返回结果?

c# sql linq entity-framework

8
推荐指数
2
解决办法
3258
查看次数

标签 统计

c# ×1

entity-framework ×1

linq ×1

sql ×1