C# 使用EF数据源中的联接向DayPilot日历添加属性

C# 使用EF数据源中的联接向DayPilot日历添加属性,c#,asp.net,entity-framework,daypilot,C#,Asp.net,Entity Framework,Daypilot,我正在使用DayPilot Lite控件创建日程安排。我想向每个事件添加其他信息,但无法通过联接以属性为目标 我的数据源: protected IEnumerable<Schedule> GetUserSched(int userId) { var query = (from i in _context.UserScheduleMaps where i.UserId == userId

我正在使用DayPilot Lite控件创建日程安排。我想向每个事件添加其他信息,但无法通过联接以属性为目标

我的数据源:

    protected IEnumerable<Schedule> GetUserSched(int userId)
    {
        var query = (from i in _context.UserScheduleMaps
                     where i.UserId == userId
                     select i.ScheduleId).ToList();

        var sched = (from i in _context.Schedules
                     join r in _context.Rooms
                     on i.RoomId equals r.RoomId
                     where query.Contains(i.ScheduleId)
                     select i).ToList();

        return sched;
    }

如何将联接表中的属性作为目标?

解决方案是将
e.DataItem.Source
转换为原始类型。然后我可以访问所需的属性

protected void calSched1_BeforeEventRender(object sender, BeforeEventRenderEventArgs e)
{
    if (e.DataItem.Source != null)
    {
        Schedule sched = (Schedule)e.DataItem.Source;
        e.Html = e.Text + ", room: " + sched.Room.RoomNameOrNumber;
    }
}
protected void calSched1_BeforeEventRender(object sender, BeforeEventRenderEventArgs e)
{
    if (e.DataItem.Source != null)
    {
        Schedule sched = (Schedule)e.DataItem.Source;
        e.Html = e.Text + ", room: " + sched.Room.RoomNameOrNumber;
    }
}