2014-09-30 2 views
0

두 목록을 비교하고 내 요구 사항에 맞지 않는 목록을 다른 목록에 추가하고 싶습니다. 나는 어떻게해야할지 모르겠다.두 목록을 비교하여 요구 사항과 일치하지 않는 목록을 다른 목록에 추가하십시오.

내가 무엇을 시도했다 :

var componentForThisProject = mdal.Get_MethodComponents_Of_Project(project.Id); 
var shapelist = this.diagram.Shapes; 


var newlist = (from shape in shapelist 
      where componentForThisProject.Any(
       p => 
       p.X_coordinate == Math.Round(shape.Position.X, 0) && 
       p.Y_coordinate == Math.Round(shape.Position.Y, 0) 
       )select shape).ToList(); 

이 작품,하지만 당신이 내가하고 싶은 것을 반대하지 볼 수있다. 일치하는 모든 것을 추가합니다. 나는 ofcourse를 == 연산자를! =로 바꾸려고 시도했지만, 이제는 새 목록에 모든 것을 추가합니다.

저는 Telerik btw를 사용하고 있습니다.

아이디어가 있으십니까?

답변

0

이 일 :

  var newlist = (from shape in shapelist 
        where !componentForThisProject.Any(
         p => 
         p.X_coordinate == Math.Round(shape.Position.X, 0) && 
         p.Y_coordinate == Math.Round(shape.Position.Y, 0) 
         )select shape).ToList(); 
관련 문제