简体   繁体   中英

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

2) Few Records exists only in test2 list

3) Few records exists in both the lists ,if exists in both the lists filter them and display as one record.

The above query works good for records less than 50k, but I have more than 200 k records to be displayed in the grid . How to improve the query using Except or other methods ?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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