小编mik*_*keM的帖子

我可以使用Contains方法的嵌入式lambda吗?

我想过滤一个列表 FindAll

如果我写:

.FindAll(
    p => p.Field == Value && 
    p.otherObjList.Contains(otherObj));
Run Code Online (Sandbox Code Playgroud)

没关系,但是如果我写的话

.FindAll(
    p => p.Field == Value && 
    p.otherObjList.Contains(
        q => q.Field1 == Value1 && 
        q.Field2 == Value2));
Run Code Online (Sandbox Code Playgroud)

我得到C#语法错误消息:未知方法FindAll(?)的... otherObjList

我无法准确定义otherObj,因为我只知道两个字段Field1和Field2的值.

我做错了什么?在这种情况下我该怎么办?

c# linq lambda contains

5
推荐指数
1
解决办法
1378
查看次数

标签 统计

c# ×1

contains ×1

lambda ×1

linq ×1