c# - linq multi left join to same property -


is possible write linq query? (in .net 3.5)

select tt.id      ,tt.detailscount      ,ttdmx.detailorder      ,ttdmx.detailtype      ,ttdm1.detailorder      ,ttdm1.detailtype      ,ttdm2.detailorder      ,ttdm2.detailtype test.testtable tt left join test.testtabledetails ttdmx on tt.id = ttdmx.causeid      , tt.maxcausedetailorder = ttdmx.detailorder left join test.testtabledetails ttdm1 on tt.id = ttdm1.causeid      , tt.maxcausedetailorder - 1 = ttdm1.detailorder left join test.testtabledetails ttdm2 on tt.id = ttdm2.causeid      , tt.maxcausedetailorder - 2 = ttdm2.detailorder 

the classes this:

public class test {   public int id {get;set;}   public ilist<testdetails> details {get;set} } 

and

public class testdetails {   public int id {get;set;}   public int detailorder {get;set;}   public int detailtype {get;set;} } 

i tried queryover can't join same property twice.

the easiest way write:

... ttdmx in db.testtabledetails.where(x =>      tt.id == x.causeid &&      tt.maxcausedetailorder == x.detailorder).defaultifempty() ... 

this translated sql left join


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -