Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/326.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# 将postgres sql转换为linq。可能吗?_C#_Sql_Linq_Postgresql - Fatal编程技术网

C# 将postgres sql转换为linq。可能吗?

C# 将postgres sql转换为linq。可能吗?,c#,sql,linq,postgresql,C#,Sql,Linq,Postgresql,我需要将下一个sql翻译成linq,有可能吗?速度大致相同 SELECT Count(tblcollectionimage.lngimageid), tblcollectiontree.lngcollectionid, tblcollection.txtname FROM (tblcollectiontree LEFT JOIN tblcollectionimage ON blcollectiontree.

我需要将下一个sql翻译成linq,有可能吗?速度大致相同

  SELECT Count(tblcollectionimage.lngimageid), 
   tblcollectiontree.lngcollectionid, 
   tblcollection.txtname 
  FROM   (tblcollectiontree  
          LEFT JOIN tblcollectionimage 
                 ON blcollectiontree.lngcollectionid = 
   tblcollectionimage.lngcollectionid) 
   JOIN tblcollection 
     ON tblcollectiontree.lngcollectionid = tblcollection.lngcollectionid 
  WHERE  lngcollectionparentid = 0 
  GROUP  BY tblcollectiontree.lngcollectionid, 
      tblcollection.txtname 
我目前有这样的linq,但它不工作

  var results =(from collection in dataBase.tblcollections 
  join collectionTree in dataBase.tblcollectiontrees on 
  collection.lngcollectionid equals collectionTree.lngcollectionid 
  into generalCollections
  from generalCollection in generalCollections 
  join images in dataBase.tblcollectionimages on 
  collection.lngcollectionid equals images.lngcollectionid 
  into generalCollectionImages
  from generalCollectionImage in 
  generalCollectionImages.DefaultIfEmpty()
  group generalCollectionImage by 
  generalCollectionImage.lngcollectionid into hello
  from hellos in hello.DefaultIfEmpty() 
  join collection in dataBase.tblcollections on 
  hello.Key equals collection.lngcollectionid

  select new
  {
      id = hello.Key,
      name = hello.Count()
  }).ToList();

欢迎来到堆栈溢出!如果你还没有,请看看这些技巧,以改进你的问题,并得到更好的答案:和。另外,请格式化您的代码,使其尽可能可读。您可能希望从我收集的信息中了解实体框架。我自己不使用.NET。