2013-02-08 58 views
0

,我有以下2下表中定義的DAG結構:LINQ到MySQL連接查詢的DAG

TABLE: ORGANISATION 
-------------------------------------------- 
|   |        | 
| ID  | Guid   NOT NULL | 
| Name | varchar(200) NOT NULL | 
| IsTop | bool   NOT NULL | 
|   |        | 
--------------------------------------------- 

TABLE: EDGE 
-------------------------------------------- 
|   |        | 
| ID  | Guid   NOT NULL | 
| From | Guid   NOT NULL | 
| To  | Guid   NOT NULL | 
|   |        | 
--------------------------------------------- 

使用LINQ,是有可能挑選所有組織,其中(ISTOP ==真OR沒有帶有To字段的EDGE指向組織的ID)使用單個查詢

回答

0

我不知道這是否會幫助你,但

var query = from org in ORGANISATION 
         where org.IsTop == "true" || 
         !(FROM ed in EDGE 
         select ed.To).CONTAINS(org.ID) 
         select org;