A、B两个表,B的ID主键引用A表的ID主键,我想查询所有B表未引用的A表数据,怎么写。sql的写法是“select * from [A] where ID not in (select ID from [B])"

解决方案 »

  1.   

    参考   var data = from a in db.A
                       where !(from b in db.B
                               select b.ID).Contains(a.ID)
                       select a;
      

  2.   

    from aa in [A] where ID not in(from bb in [B] select ID) select *
    自己试试  大致就是这样
      

  3.   

    我很讨厌linq to sql 。效率太低