Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将sql查询转换为linq表达式_C#_Sql_Linq - Fatal编程技术网

C# 将sql查询转换为linq表达式

C# 将sql查询转换为linq表达式,c#,sql,linq,C#,Sql,Linq,我想通过方法中的传入进程Id选择表进程系统之外的所有系统,我已经编写了SQL,但现在我需要LINQ。。请帮帮我 如何将这样的SQL查询转换为LINQ: SELECT * FROM Systems WHERE id NOT IN ( SELECT systemid FROM Process_Systems WHERE processId = 4 ); 或者这个(这些是相等的) 最后,您将得到IEnu

我想通过方法中的传入进程Id选择表进程系统之外的所有系统,我已经编写了SQL,但现在我需要LINQ。。请帮帮我 如何将这样的SQL查询转换为LINQ:

  SELECT   *
   FROM     Systems
     WHERE    id NOT IN (
       SELECT systemid
        FROM   Process_Systems
       WHERE  processId = 4
     );
或者这个(这些是相等的)


最后,您将得到IEnumerable对象。如果我有你的问题。

请给我们一些努力。你试过什么?我试过编辑我的问题。。。请再看一次。@James,至少免费版本没有从
SQL
转换到
Linq
,只有相反的方式。@Silvermind不管怎样,OP仍然可以自己进行实验并找出答案。
  SELECT   Systems.*
  FROM     Systems LEFT JOIN Process_Systems ps
    ON ps.systemId = Systems.id
  AND ps.processId = 4
  WHERE    ps.systemId IS NULL;
var query = from system in Systems
             where id != (from process_system in Process_Systems
                          where process_system.processId == 4
                          select process_system.systemid).First()
             select system;