本文介绍了查询主体必须以select子句或group子句结尾.为什么这里是错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的linq语句出了什么问题,我在做什么错了?
What is wrong with my linq statement, what am I doing wrong?
if (this.selectLBU.HtUsers.Any())
{
reportRowItems = (from r in reportRowItems
from bu in r.User.HtBusinessUnits
where bu.LocationBusinessUnitId == selectLBU.LocationBusinessUnitId).ToList();
推荐答案
您需要添加select子句以告诉您查询需要哪些数据. msdn文章 描述了基本查询操作和结构.
You need to add select clause to tell what data you require from query. This msdn article describes the basic query operation and structure.
reportRowItems = (from r in reportRowItems
from bu in r.User.HtBusinessUnits
where bu.LocationBusinessUnitId == selectLBU.LocationBusinessUnitId
select r
).ToList();
要获得两个表的组合,可以使用投影.
To get combination of both tables you can use projection.
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();
这篇关于查询主体必须以select子句或group子句结尾.为什么这里是错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!