sql server - Convert right outer join to Linq query in EF -


i want convert below sql query linq query confused:

select * dbo.vahed inner join dbo.vahedmahsol on dbo.vahed.vahedid = dbo.vahedmahsol.vahedid right outer join dbo.mahsol on dbo.vahedmahsol.mahsolid = dbo.mahsol.mahsolid 

i wrote code:

vaheds = (   in db.spgetvahedbywhatwhere(what, wherestr, int.parse(whattype), new guid(shahrid))   join gr in db.gorohsenfis on i.gorohsenfiid equals gr.gorohsenfiid   join ct in db.contacts on i.vahedid equals ct.vahedid   join vm in db.vahedmahsols on i.vahedid equals vm.vahedid   select ) .tolist(); 

but don't know how convert

right outer join dbo.mahsol on dbo.vahedmahsol.mahsolid = dbo.mahsol.mahsolid 

to linq query.

first of can rewrite sql query use left outer join instead of right outer join (because easier convert linq):

select * dbo.mahsol left outer join dbo.vahedmahsol on dbo.mahsol.mahsolid = dbo.vahedmahsol.mahsolid inner join dbo.vahed on dbo.vahedmahsol.vahedid = dbo.vahed.vahedid 

now can convert query above in linq this:

vaheds = (   m in db.mahsols   join vm1 in db.vahedmahsols on m.mahsolid equals v.mahsolid vmgroup   vm in vmgroup.defaultifempty()   join in db.spgetvahedbywhatwhere(what, wherestr, int.parse(whattype), new guid(shahrid))     on vm.vahedid equals i.vahedid   join gr in db.gorohsenfis on i.gorohsenfiid equals gr.gorohsenfiid   join ct in db.contacts on i.vahedid equals ct.vahedid   select ).tolist(); 

i have no way of testing this, hope works.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -