Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/68.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# 查询主体必须以select子句或group子句c结尾_C#_Sql_Linq - Fatal编程技术网

C# 查询主体必须以select子句或group子句c结尾

C# 查询主体必须以select子句或group子句c结尾,c#,sql,linq,C#,Sql,Linq,虽然这是一个经常被问到的问题,但我还没有找到适合我的情况的解决方案 我在以下代码中收到上述编译错误: var data = from g in db.MD_import_results .Where((fProjectID == tProjectID) && (g.md_CheckResults) != null || (g.md_CheckResults1) != null || (g.md_CheckResults2) != null || (g.

虽然这是一个经常被问到的问题,但我还没有找到适合我的情况的解决方案

我在以下代码中收到上述编译错误:

var data = from g in db.MD_import_results
    .Where((fProjectID == tProjectID) && (g.md_CheckResults) != null 
    || (g.md_CheckResults1) != null || (g.md_CheckResults2) != null 
    || (g.md_CheckResults3) != null).Select(
            p => new
            {
                p.AccountID,
                p.md_HouseNumber,
                p.md_StreetPreDirectional,
                p.md_StreetName,
                p.md_StreetSuffix,
                p.md_StreetPostDirectional,
                p.md_Suite,
                p.md_City,
                p.md_State,
                p.md_ZipCode,
                p.md_CheckResults,
                p.md_CheckResults1,
                p.md_CheckResults2,
                p.md_CheckResults3,
                p.ProjectID
            }); 

感谢您的建议。

编写LINQ查询有两种方法,查询语法和方法语法

查询语法如下所示

from g in x
  where g.foo == bar
  select g.baz;
x.Where(g => g.foo == bar).Select(g => g.baz);
方法语法看起来像

from g in x
  where g.foo == bar
  select g.baz;
x.Where(g => g.foo == bar).Select(g => g.baz);

你把两者结合起来了。你从x中的g开始写作,然后继续写作。在哪里。。。。选择一种语法并坚持使用。

编写LINQ查询有两种方法,查询语法和方法语法

查询语法如下所示

from g in x
  where g.foo == bar
  select g.baz;
x.Where(g => g.foo == bar).Select(g => g.baz);
方法语法看起来像

from g in x
  where g.foo == bar
  select g.baz;
x.Where(g => g.foo == bar).Select(g => g.baz);

你把两者结合起来了。你从x中的g开始写作,然后继续写作。在哪里。。。。选择一种语法并坚持使用。

只需在一定程度上去掉from g,因为您似乎正在使用方法语法。不要使用“from”语法。使用以下命令:var data=db.MD_import_results。其中………..只需在某种程度上去掉from g,因为您似乎正在使用方法语法。不要使用“from”语法。使用以下内容:var data=db.MD\u import\u results.Where。。。。。。。。。。。。