I am trying to make this simple SQL LINQ query. But that gives me an error.
Here is the SQL query to convert to LINQ
DECLARE @groupID int SET @groupID = 2 SELECT * FROM dbo.Person p LEFT JOIN dbo.PersonGroup pg ON ( p.PersonID = pg.PersonID AND pg.GroupID = @groupID)
Ignore @groupID. which will be provided as a function parameter for the LINQ query.
Here is the LINQ query that I tried.
from p in Person join pg in PersonGroup on new { p.PersonID, groupID } equals new { pg.PersonID, pg.GroupID } into t from rt in t.DefaultIfEmpty()
Where groupID is provided as a function parameter. Both GroupID and PersonID are int. But this gives me the following error:
Error 2 The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'GroupJoin'.
A little help would be appreciated.
source share