sql - Linq to Entities cycling left outer joins -


i have following problem linq entities.

diagram: enter image description here

linq entities query (incomplete yet):

from in anlaesse  join b in beurteilung on a.anlassid equals b.anlassid ab  b in ab.defaultifempty()  join r in rangliste on a.anlassid equals r.anlassid  join p in pony on r.ponyid equals p.ponyid rp  p in rp.defaultifempty()  a.anlassid == 67  select new      {              beurteilungid = b.beurteilungid == null ? 0 : b.beurteilungid,      ponyid = p.ponyid == null ? 0 : p.ponyid,      name = p.name,      ponyname1 = r.ponyname1,      anlassid = a.anlassid == null ? 0 : a.anlassid      }  

generated sql:

select  [extent1].[anlassid] [anlassid],  case when ([extent2].[beurteilungid] null) 0 else  [extent2].[beurteilungid] end [c1],  case when ([extent4].[ponyid] null) 0 else [extent4].[ponyid] end [c2],  [extent4].[name] [name],  [extent3].[ponyname1] [ponyname1]     [sspv].[anlaesse] [extent1]  left outer join [sspv].[beurteilung] [extent2] on [extent1].[anlassid]  = [extent2].[anlassid]  inner join [sspv].[rangliste] [extent3] on [extent1].[anlassid] =  [extent3].[anlassid]  left outer join [sspv].[pony] [extent4] on [extent3].[ponyid] =   [extent4].[ponyid]  67 = [extent1].[anlassid]  

problem i'm unable add left outer join between pony , beurteilung because tables "used" in query. without result wrong because returns each pony beurteilung.

let's assume want left join pony beurteilung. , let's assume both have ponyid property. clause act inner join:

where p.ponyid == b.ponyid 

a clause act left join.

where b == null || p.ponyid == b.ponyid 

however, finding hard because doesn't using entity framework properly. have mapped navigation properties or collections? if haven't add them because sort of point of ef. if have shouldn't have need use inner or left joins; traverse navigation properties.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -