Hi there i am a newbie in linq, i tried to do a left join query using LinQ. This is my query:
SELECT B.[ID]
,A.[GroupID]
,B.[Year]
,B.[Month]
,B.[Col1]
,B.[Col2]
,B.[Col3]
,B.[Col4]
,B.[Col5] FROM MsGroups A
LEFT JOIN MsCKPNS B on
A.GroupId = B.GroupId and B.Year = 2014 and B.Month = 3
Here is my linq query:
Dim msckpn = (From g In db.MsGroup
Group Join c In db.MsCKPNs
On g.GroupId Equals c.GroupID Into
Group From a In Group.DefaultIfEmpty() _
Where a.Month = Month And a.Year = Year
Select New MsCKPN With {
.ID = Nothing,
.GroupID = g.GroupId,
.Month = Month,
.Year = Year,
.Col1 = a.Col1,
.Col2 = a.Col2,
.Col3 = a.Col3,
.Col4 = a.Col4,
.Col5 = a.Col5
}).ToList
But, it shows error : The entity or complex type 'MvcMISD.MsCKPN' cannot be constructed in a LINQ to Entities query.
What should i do to fix the query?
Thanks