Click here to Skip to main content
15,037,168 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more: , +
i have this entity framework code:

VB
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

this error accoured:
Only parameterless constructors and initializers are supported in LINQ to Entities.


description:
i want group by CDATE and sum of TOTALVH and put it in PointXY Class Like this
VB
PointXY {.Y = Sum(TOTALVH), .X = CDATE})


sql Query :
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


please help me,thanks all.
Posted
Updated 14-Jun-20 5:00am

1 solution

var data = from a in tablename.groupby(a=>a.cdate)
.select (al => new datamodle{expr1=sum(al.first().taotalvj,cdate=al.first().cdate) });
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900