c# - 完整组满足条件的 LINQ 查询

标签 c# linq

我存储了很多这样的文本行:

1|1000|1|0|Text Message|||
1|1000|1|1|Text Message|||
1|1000|2|0|Text Message|||
1|1000|2|1|Text Message|||
1|1000|3|0|Text Message|||
1|1001|1|0|Text Message|||

在集合中:List<ObjRow> listRows

这是相应的类:

public class ObjRow
{
    private string n_Par { get; set; }
    private string n_Rad { get; set; }
    private string n_Lang { get; set; }
    private string n_Line_Mex { get; set; }
    private string text_Mex { get; set; } 
    private int n_Row { get; set; }
}

我想找到哪些线组(按属性 n_Rad 、2° PIPE 值分组)没有值 n_Lang == 3 (3° 管道值)。

如何使用 LINQ 执行此操作?

最佳答案

这应该是你想要的:

var groupsWithoutLang3  = listRows
             .GroupBy(o => o.n_Rad)
             .Where(g => !g.Any(o => o.n_Lang == "3"));

它仅选择没有 ObjRown_Lang == "3" 的组。

关于c# - 完整组满足条件的 LINQ 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16565804/

相关文章:

c# - 如何在 Dryloc (IOC) 中注册对象

c# - Linq:当我在 XML 文件中有命名空间时,元素不起作用

c# - LINQ 中的可迭代析取

c# - 为什么我的 linq 别名超出范围?

c# - 如何从列表中删除在同一列表中有父项的项目

c# - 两个winforms一个模态的对话框情况

c# - 错误 : The Out Parameter must be assigned before control leaves the current method

c# - 需要有关使用 Linq 在循环中添加Where 子句的帮助

c# - 关于开发专业 MS Word 附加组件的有用建议

c# - 在 LINQ 中对相似列进行分组并连接其他列