LINQ LEFT JOIN where clause not working

前端 未结 3 1608
野趣味
野趣味 2021-01-05 18:04

I need to return a list of all the events and any rsvps a user may have for an event. However, regardless of the username I pass, It returns every single rsvp. My linq Query

3条回答
  •  清酒与你
    2021-01-05 18:49

    If you just want to filter the RSVPs property of your Events in-place, then I guess you probably could do use something like

    var events = _context.Context.Events;
    
    foreach(var event in events)
    {
        // Assuming the property is named RSVPs
        event.RSVPs = event.RSVPs.Where(o => o.UserName.Equals(userName));
    }
    
    return events;
    

    I wouldn't consider it that neat though.

提交回复
热议问题