未定义的linq联合组
我正在从web服务调用以下函数,但无法定义对象未定义的linq联合组,linq,linq-to-entities,Linq,Linq To Entities,我正在从web服务调用以下函数,但无法定义对象 Dim x = (From a In _db.report _ Select ep = a.CurrentReport, CuCy = a.Current_Cycle) _ .Union _ (From b In _db.Counts _ Group b By b.Year, b.Report Into k() _ <--------(this is undefined) Select ep
Dim x = (From a In _db.report _
Select ep = a.CurrentReport, CuCy = a.Current_Cycle) _
.Union _
(From b In _db.Counts _
Group b By b.Year, b.Report Into k() _ <--------(this is undefined)
Select ep = b.Report, CucY = b.Year).ToList().Take(10)
这是在联合查询中执行group by的正确方法吗
如果有任何帮助,我将不胜感激。VB中的分组语法与C略有不同。Group By要求您在Group中声明,而不是对新结构使用别名。查看以下各项是否适用于您:
Dim x = (From a In _db.report _
Select ep = a.CurrentReport, CuCy = a.Current_Cycle) _
.Union _
(From b In _db.Counts _
Group By b.Year, b.Report Into Group _ <--------(this is undefined)
Select ep = Key.Report, Key.Year).ToList().Take(10)
我不完全确定这一点,但我认为k后面的括号是不需要的:groupby[…]进入k Select[…]它们是自动添加的。我已经删除了它们,但它会将它们重新添加。
From b in _db.Counts
Select b.Report, B.Year
Distinct