C# Lambda表达式 两个list取交集 做筛选

        public IList getEngineerByCenterPoint(float latitude, float longitude)
        {
            MapAddress mapAddress = new MapAddress(latitude, longitude);
            List markers = (List)getEngineerRecent();
            List maps = (List)MapHelper.GetPointsByDistance(mapAddress,200000, markers);
            //return markers.Where(a => maps.Exists(t => a.latitude.Equals(t.lat))).ToList();  方法1
            return markers.Where(a => maps.Where(t => a.latitude == t.lat).Any()).ToList();  // 方法2
            //return markers.Where(a => !maps.Where(t => a.latitude == t.lat).Any()).ToList();  //除去交集数据,加 '!'
        }

 

你可能感兴趣的:(搬砖)