2012-02-26 69 views
0

我無法將sql命令代碼轉換爲linq。 請SQL命令sql命令linq

select * from Student Where Id Not In (select Nm from Student) 

感謝

+0

轉換爲LINQ,而不是其中Id!=牛?從s在學生在哪裏Id!= Nm選擇s – tawman 2012-02-26 05:40:50

回答

2

試試這個,

YourDataContext dc = new YourDataContext(); 

var query = 
    from st in dc.Students 
    where !(from n in dc.Students 
      select n.Nm) 
      .Contains(st.Id) 
    select st; 
+0

謝謝。謝謝... – maktab 2012-02-26 06:11:27

+0

@maktab:跳你知道怎麼說謝謝StackOverflow。 (接受如果這對你有用) – 2012-02-26 06:20:56

+0

@maktab如果這是你的問題的答案,通過點擊正確的標記標記爲答案。這對其他人也有幫助:) – 2012-02-26 09:34:32