内字符串比较数组元素我有这样的模式:与LINQ查询
public class Model_Test
{
public string Prop1 { get; set; }
public string Prop2 { get; set; }
public string[] Prop3 { get; set; }
}
检查Prop3
是一个数组。里面Prop3
值也像{"answer1","answer2","answer3"}
我需要做一个查询,只需要在Model_Test
对象,其中answer3
为“是”,我triyng这样的:
result = from q in Model_Test
where q.Prop3[2] == "Yes"
select new { Name = Prop1, Value = Prop2 };
当我执行此查询我收到此错误:
无法识别的表达式节点:ArrayIndex
我认为这个问题是我的查询中的这一部分:q.Prop3[2]
我感谢你的帮助。
''Model_Test''是查询代码块中的一个集合吗? –
是Model_Test是一个集合 –
和这个:''Name = Prop1,Value = Prop2''应该是:''Name ='q.Prop1,Value = q.Prop2'' –