我正在尝试找到一种方法来比较 LINQ 结果中的元素
这是 LINQ 代码
var sets =
from a in patient.AsParallel()
from b in patient.AsParallel()
from c in patient.AsParallel()
from d in patient.AsParallel()
where a.VisitNum < b.VisitNum && b.VisitNum < c.VisitNum && c.VisitNum < d.VisitNum
select new { a, b, c, d };
var sets1 =
from a in patient1.AsParallel()
from b in patient1.AsParallel()
from c in patient1.AsParallel()
from d in patient1.AsParallel()
select new { a, b, c, d };
我用它来比较这段代码,但每次都给我假
if (Enumerable.SequenceEqual(sets, sets1) == true)
有什么建议吗?
// 更新为 Jani 的答案
public class Result
{
public ACVsize5 a { get; set; }
public ACVsize5 b { get; set; }
public ACVsize5 c { get; set; }
public ACVsize5 d { get; set; }
}
public override Boolean Equals(Result other)
{
return other.a.date.ToString() == a.date.ToString() && other.a.RaId.ToString() == a.RaId.ToString() && other.b.date.ToString() == b.date.ToString() && other.b.RaId.ToString() == b.RaId.ToString() && other.c.date.ToString() == c.date.ToString() && other.c.RaId.ToString() == c.RaId.ToString() && other.d.date.ToString() == d.date.ToString() && other.d.RaId.ToString() == d.RaId.ToString();
}
var sets =
from a in patient
from b in patient
from c in patient
from d in patient
where a.VisitNum < b.VisitNum && b.VisitNum < c.VisitNum && c.VisitNum < d.VisitNum
select new Result { a = a, b = b, c = c, d = d };
var sets1 =
from t in patient1
from y in patient1
from u in patient1
from p in patient1
where t.VisitNum < y.VisitNum && y.VisitNum < u.VisitNum && u.VisitNum < p.VisitNum
select new Result { a = t, b = y, c = u, d = p };
但我在覆盖方法上遇到错误
//Error 1 no suitable method found to override