简体   繁体   English

过滤列表和联合(或Concat)中的重复项

[英]Filter duplicates in the Lists and Union(or Concat)

   var testfilter = ( from p in test1  where !(from Q in test2 select new {Q.Website,Q.SSN,Q.Class})
                       Contains(new {p.Website,P.SSN,P.Class}) Select P).ToList();

    List<testResults> ResultList = (from R in testfilter  
                                    select new testResults  
                                    {  
                                       Website = R.Website,
                                        SSN = R.SSN,
                                        class = R.class, List1 = 'Yes'  
                                    }.ToList()  
                                   .Union (from Q in test2 
                                    select new testResults    
                                    {   
                                      Website = Q.Website,
                                      SSN = Q.SSN,class = Q.class, Status = Q.Status,
                                      List2 = 'Yes'   
                                   }.ToList(); 

I have to check following conditions in the below lists 我必须检查以下列表中的以下条件

1) Few records exists only in test1 List 1)很少有记录仅存在于test1列表中

2) Few Records exists only in test2 list 2)很少的记录仅存在于test2列表中

3) Few records exists in both the lists ,if exists in both the lists filter them and display as one record. 3)两个列表中都没有记录,如果两个列表中都存在,则将其过滤并显示为一个记录。

The above query works good for records less than 50k, but I have more than 200 k records to be displayed in the grid . 上面的查询适用于少于50k的记录,但是我有超过200k的记录要显示在网格中。 How to improve the query using Except or other methods ? 如何使用Except或其他方法改善查询?

您可以尝试使用类似的不确定性,例如不确定是否这是解决问题的最佳方法

 List<testResults> distinctResultList = ResultList.Distinct().ToList();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM