gpt4 book ai didi

c# - 查询主体必须以 select 子句或 group 子句结尾为什么这里会出错?

转载 作者:可可西里 更新时间:2023-11-01 09:02:12 25 4
gpt4 key购买 nike

我的 linq 语句有什么问题,我做错了什么?

if (this.selectLBU.HtUsers.Any())
{
reportRowItems = (from r in reportRowItems
from bu in r.User.HtBusinessUnits
where bu.LocationBusinessUnitId == selectLBU.LocationBusinessUnitId).ToList();

最佳答案

您需要添加 select 子句来告诉您需要从查询中获取哪些数据。这msdn article描述了基本的查询操作和结构。

 reportRowItems = (from r in reportRowItems
from bu in r.User.HtBusinessUnits
where bu.LocationBusinessUnitId == selectLBU.LocationBusinessUnitId
select r
).ToList();

要获得两个表的组合,您可以使用投影。

reportRowItems = (from r in reportRowItems
from bu in r.User.HtBusinessUnits
where bu.LocationBusinessUnitId == selectLBU.LocationBusinessUnitId
select new {r.AttributeName1, r.AttributeName2, bu.AttributeName1}
).ToList();

关于c# - 查询主体必须以 select 子句或 group 子句结尾为什么这里会出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13489436/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com