我已经定义了两个列表,现在要过滤escHistory
列表Application
属性匹配filterRIDS
RID值。如何通过int列表中的属性值过滤列表?
但是,通过LINQ筛选出escHistory
,我得到的返回计数为零。虽然列表确实包含应用程序属性值与filterRIDS
中定义的应用程序属性值匹配的记录。
问题:
如何通过另一个列表中的属性值过滤列表?
这是过滤器代码的基本要点是:
List<int> filterRIDS = new List<int> { 115841, 200463 };
List<Escalation> escHistory = new List<Escalation>();
//Filter list by RID's matching
escHistory = escHistory.Where(r => r.Application.Contains(filterRIDS.ToString())).ToList<Escalation>();
好吧,忘了提及'r.Application'是一个像'123456 MyTestApp'这样的字符串类型。所以在我的情况下,我会得到解析到int之前的子字符串。 'escHistory = escHistory.Where(r => filterRIDS.Contains(int.Parse(r.Application.Substring(0,6))))。ToList(); ' –
@BrianJ或你分裂'r.Application.Split('').First()' –