c#获取两个数据的不同

DataSet ds1 = PeopleSetBLL.GetPeopleGroup();//获取人员合集
                DataTable dt1 = ds1.Tables[0];
                DataSet ds2 = PeopleSetBLL.SelectByName(null);//获取人员设置中人员合集
                DataTable dt2 = ds2.Tables[0];

                var qry1 = dt1.AsEnumerable().Select(a => new { MobileNo = a["PeopleName"].ToString() + a["IDCard"].ToString() });
                var qry2 = dt2.AsEnumerable().Select(b => new { MobileNo = b["PeopleName"].ToString() + b["IDCard"].ToString() });

                var exceptAB = qry1.Except(qry2);

                if (exceptAB.Count() > 0)
                {
                    DataTable dtMisMatch = (from a in dt1.AsEnumerable() join ab in exceptAB on (a["PeopleName"].ToString() + a["IDCard"].ToString()) equals ab.MobileNo select a).CopyToDataTable();
                    }
 

你可能感兴趣的:(c#,开发语言)