Accepted answer

for cross join just add another from:

from fees in session.query<fee>()
//cross join:
from feetypes in session.query<session.query<fee>()
join ...
join ...
// left join:
join feetypelink in session.query<feetypelink>() on 
new {fees.feeid,feetypes.feetypeid} equals new{feetypelink.feeid,feetypelink.feetypeid} 
into gr
from res in gr.defaultifempty() .....


you can use this:

from a in
join b in on equals b.idofa //inner join for entities without relationships
join c in ctx.cs on 1 equals 1 //inner join with constant condition


just throw another from in there, since you're not truly "joining" the tables, from a linq perspective.

from fees in session.query<fee>()
join feecategories in session.query<feecategory>() on equals
join feecompanytype in session.query<feecompanytype>() on equals
from feetype in session.query<feetype>()
select ...


the original query is nonsense and not really doing a cross join

in fact it is equivalent to this

select various a,b,c,d, and e columns 
from fee a 
inner join feecategory b on a.categoryid = b.feecategoryid 
inner join feecompanytype c on a.feeid = c.feeid 
left join feetypelink d on a.feeid = d.feeid 
left join feetype e on e.feetypeid = d.feetypeid 

now you should be able to convert it easily to linq to sql. i don't use that much so will leave others to fill in the details. you don't need anything fancy though.

Related Query