protected override object returnResult(Hashtable results)
        {
            if (results == null)
                return null;            var entire = (new DataTable()).AsEnumerable();
            foreach (DictionaryEntry entry in results)
            {
                if (entry.Value == null)
                    continue;                DataTable tbl = (DataTable ) entry.Value ;
                if (tbl.Rows.Count > 0)  这里Count==2        
                     entire.Union<DataRow>(tbl.AsEnumerable()); 这句话执行到了            
            }            if (entire.Count() > 0)  为什么这里Count=0?               
                return entire.CopyToDataTable<DataRow>();
            else
                return null;
        }

解决方案 »

  1.   

          protected override object returnResult(Hashtable results)
            {
                if (results == null)
                    return null;            var entire = (new DataTable()).AsEnumerable();
                foreach (DictionaryEntry entry in results)
                {
                    if (entry.Value == null)
                        continue;                DataTable tbl = (DataTable ) entry.Value ;
                    if (tbl.Rows.Count > 0)  这里Count==2        
                         entire.Union<DataRow>(tbl.AsEnumerable()); 这句话执行到了            
                }            if (entire.Count() > 0)  为什么这里Count=0?               
                    return entire.CopyToDataTable<DataRow>();
                else
                    return null;
            }
      

  2.   

    这个是生成两个序列的并集,如果是N个集合的并集的话,那应该要重写一下Union方法的哦
    using System; using System.Collections.Generic; public class UTest { public static void Main() { ICollection<int> unionResult = UnionHelper<int>.Union( new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, new int[] { 1, 3, 5, 7, 9 }, new int[] { 1, 4, 7 } ); foreach (int i in unionResult) { Console.WriteLine(i); // 1,7  } } } class UnionHelper<T> { public static ICollection<T> Union(params ICollection<T>[] sets) { List<T> result = new List<T>(); if (sets.Length > 0) { ICollection<T> firstSet = sets.GetValue(0) as ICollection<T>; foreach (T element in firstSet) { bool isUnionElement = true; foreach (ICollection<T> set in sets) { if (!object.ReferenceEquals(set, firstSet) && !set.Contains(element)) { isUnionElement = false; break; } } if (isUnionElement) { result.Add(element); } } } return result; } }
    http://topic.csdn.net/u/20080518/09/9b9733cc-7415-411f-8b9e-8aa402bd9367.html
      

  3.   

    我觉得肯定的重写这个方法了,只有是值类型时不需要重写吧,引用类型应该是必须重写,否则对于应用类型并集就是所有的DataRow