'Difference in Postgres SQL query result in Shell execution vs Entity Framework SqlRaw
I have following query, which when executed from postgres Shell gets me correct meetings and includes participants per each meeting
SELECT id, subject, organizer, starttime, endtime, tmp.participants
from "Meetings" m
left join lateral (
select jsonb_agg(row_to_json(tp)) as participants
from (select p.name, p.title
from "Meetings_Participants" mp
inner join "Participants" p on mp."ParticipantId" = p.id
where mp."MeetingId" = m.id
) tp
) tmp on true
WHERE starttime::date <= NOW()::date
and endtime::date >= NOW()::date;
when I run this equivalent in Entity Framework I do get correct meetings but participants list is always Null ???
return db.Meetings.FromSqlRaw<Meeting>(
"SELECT id, subject, organizer, starttime, endtime, tmp.participants " +
"from \"Meetings\" m " +
"left join lateral (" +
"select jsonb_agg(row_to_json(tp)) as participants " +
"from (select p.name, p.title " +
"from \"Meetings_Participants\" mp " +
"inner join \"Participants\" p on mp.\"ParticipantId\" = p.id " +
"where mp.\"MeetingId\" = m.id " +
") tp" +
") tmp on true " +
"WHERE starttime::date <= NOW()::date "+
"and endtime::date >= NOW()::date"
).ToList<Meeting>();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
