我的虚拟机中有 Sessions 属性
private ObservableAsPropertyHelper<IEnumerable<SessionViewModel>> _Sessions;
public IEnumerable<SessionViewModel> Sessions
{
get { return _Sessions.Value; }
}
我正在尝试像这样在构造函数中设置它
this.WhenAny(x => x.LocationsViewModel.CurrentLocation, x => x.Date, (location, date) => location.Value)
.Where(x => x != null)
.Select(x => FilterSessions(x.Id, Date))
.ToProperty(this, x => x.Sessions);
FilterSessions 看起来像这样
private IEnumerable<SessionViewModel> FilterSessions(Guid locationId, DateTime date)
{
return _allSessions
.Where(s => s.SessionLocationId == locationId && s.StartTime.Date == date.Date)
.Select(s => new SessionViewModel(s));
}
它返回 10 个 SessionViewModel,但 _Sessions 从未设置。