2009-05-05 3 views
1

기준에 따라 세트를 뺄셈을하고 싶습니다.Exclusary Set Syntax with Linq, VB

select table1.columnn1 
     ,table1.column2 
    from table1, table2 
where (table1.column1.value1 not in table2.column1 
     and 
     table1.column2.value2 not in table2.column2) 

내가 여기에 대해 그것을 만들 수 있습니다 :

dim list = From tbl1 In table1 Where tt.column1 ... 

을 그리고 거기에서 내가 무엇을해야할지 모르는 의사 쿼리는 같을 것이다.

답변

2

LINQ의 Except 표준 쿼리 연산자를 살펴보십시오. 이렇게하면 두 시퀀스의 차이가 설정됩니다.

http://msdn.microsoft.com/en-us/library/system.linq.enumerable.except.aspx

은 또한 아래의 샘플 당으로, 당신이 원하는 것을 달성하기 위해 Contains 연산자를 사용할 수 있습니다 :

dim table2Col1 = from t in table2 select t.column1 
dim table2Col2 = from t in table2 select t.column2 

dim results = _ 
    from t in table1 _ 
    where not table2Col1.Contains(t.column1) _ 
    and not table2Col2.Contains(t.column2) _ 
    select new with { .column1=t.column1, .column2=t.column2 } 
+0

덕분에 많이, 당신은 확실히 올바른 방향으로 날 놨습니다. – Daniel