0

我有这个实体框架代码:

repository.GetObjectQuery(Of COUNL1)().
     Where(Function(a) a.CDATE >= '2012/01/01' And 
           a.CDATE <= '2012/12/01' And 
           COID = 88 ).
     GroupBy(Function(m) m.CDATE).
     Select(Function(n) New PointXY With {
        .Y = n.Sum(Function(k) k.TOTALVH), 
        .X = n.First().CDATE}).
     ToList()

出现此错误:

Only parameterless constructors and initializers are supported in LINQ to Entities.

描述:我想按 CDATE 和 TOTALVH 的总和进行分组,并将其放在 PointXY 类中,像这样

PointXY {.Y = Sum(TOTALVH), .X = CDATE})

sql查询:

SELECT        SUM(TOTALVH) AS EXPR1, CDATE
FROM            COUNL1
WHERE        (CDATE >= '2012/01/01') AND (CDATE <= '2012/12/01') AND   (COID  = 88)
GROUP BY CDATE 

请帮助我,谢谢大家。

4

1 回答 1

0

错误信息是:

LINQ to Entities 仅支持无参数构造函数和初始化程序。

所以去检查你的PointXY班级。

如果它没有无参数构造函数......只需添加一个!

Public Sub New()
End Sub
于 2012-10-06T18:41:46.317 回答