c# - How can I rewrite the following SQL query into LINQ query? -


i want rewrite following sql query in linq. problem don't know how write add and(&&) operator linq left join(look @ 2nd left join). can please?

select      emp.employeeid,             dsg.name,             pob.companycontribution,             pob.employeecontribution,             pob.openingincome         hrmemployees emp left join   hrmdesignations dsg on emp.hrmdesignationid=dsg.id left join   pfmopeningbalance pob on emp.id=pob.hrmemployeeid , pob.cmncalendaryearid=2       emp.id=6 

i tried following one. getting compile error-

from emp in dbcontext.employeelist                         join dsg in dbcontext.hrmdesig on emp.hrmdesignationid equals dsg.id dsgleftjoin                         dsglj in dsgleftjoin.defaultifempty()                         join pob in dbcontext.pfopeningbalances on emp.id equals pob.hrmemployeeid pobleftjoin                         poblj in pobleftjoin.defaultifempty() && poblj.cmncalendaryearid == clndrid                         emp.id==empid                         select new                         {                             empidr = emp.id,                             employeeid = emp.employeeid,                             employeename = emp.name,                             designation = dsglj.name,                             openingincome = poblj.openingincome,                             employeecontribution = poblj.employeecontribution,                             companycontribution = poblj.companycontribution                         } 

try this.

 (from emp in hrmemployees   join dsg in hrmdesignations    on  emp.hrmdesignationid equals dsg.id   join pob in pfmopeningbalance    on emp.id equals pob.hrmemployeeid , pob.cmncalendaryearid equals 2   egroup   emps in egroup.defaultifempty()   emp.id=6   select new     {         employeeid =emp.employeeid,         name=dsg.name,         companycontribution=pob.companycontribution,         employeecontribution=pob.employeecontribution,         openingincome=pob.openingincome     }).tolist(); 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -