I tried to do a left join in LINQ as follows:
(from opr in db.Operacao
join vol in db.Volume on new { VOL_CODBAR = opr.OPR_CODBAR } equals new { VOL_CODBAR = vol.VOL_CODBAR } into vol_join
from vol in vol_join.DefaultIfEmpty()
select new {
opr.OPR_IDX,
opr.OPR_CODEMP,
opr.OPR_CODFIL,
opr.OPR_NUMVEI,
opr.OPR_TIPOPR,
vol.VOL_TITLE
})
But at runtime, and the exception is generated:
LINQ to Entities does not recognize the 'System.Collections.Generic.IEnumerable
1[ImprotecSistemas.PackLocator.PackServer.DataAccess.vwObtemFuncionario] DefaultIfEmpty[Operacao](System.Collections.Generic.IEnumerable
1 [ImprotecSistemas.PackLocator.PackServer.DataAccess.Operacao]' method, which can not be converted into a storage expression. >
Here's what I want in SQL:
Select *
From operacao opr
left join volumes vol on vol.VOL_CODBAR = OPR.OPR_CODBAR
I'm using Entity Framework 3.5 C #