c# - How can I do an outer join with EF 6.1 -


i have following:

 var tests = await db.tests             .include(t => t.exam)             .where(t => t.teststatusid == 1)             .select(t => new testdto             {                 examname = t.exam.name,                 id = t.testid,                 questionscount = t.questionscount,                 title = t.title             })             .tolistasync();         return ok(tests); 

how can make still returns tests if there no matching exam particular test?

try this:

//first step     var tests = db.tests         .include(t => t.exam)         .where(t => t.teststatusid == 1);          //next step         if(testc.exam != null && testc.exam.count > 0)         {             testc = testc.select(t => new testdto         {             examname = t.exam.name,             id = t.testid,             questionscount = t.questionscount,             title = t.title         });         } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -