I do have a table named EVENT with PK eventID.
and other table as eventartistmapper with PK eventartistmapperid and FKeventid.
and also table as evendetail with PK as eventdetailid and FKeventid. this table contain artistid column.
I need to fetch record which shows all the events as per the artist.
Equivalent sql will be like this :
select *
from event e
inner join eventdetail ed on ed.eventid = e.eventid
inner join eventartistmapper eam on eam.eventid = e.eventid
where eam.artistid = 2
this is the LINQ i wrote for this, it is not returning any records in it.
But while executing sql, I am getting a record.
return db.Event.Join(db.EventArtistMapper,
e => e.EventArtistMapperId,
eam => eam.EventArtistMapperId,
(e, eam) => new { Event = e, EventArtistMapper = eam})
.Where(bothTables => bothTables.EventArtistMapper.ArtistId == artistId)
.Select(bothTables => new Event
{
EventId = bothTables.Event.EventId,
EventName = bothTables.Event.EventName,
EventDescription = bothTables.Event.EventDescription,
EventStartDate = bothTables.Event.EventStartDate,
EventEndDate = bothTables.Event.EventEndDate,
EventStartTime = bothTables.Event.EventStartTime,
VenueId = bothTables.Event.VenueId,
EventDetail = bothTables.Event.EventDetail,
EventArtistMapper = bothTables.Event.EventArtistMapper
});
db is a dbcontext.
Can anybody help me, have I done anything wrong
Thanks in advance.