我試圖通過保存在裏面的日期來過濾observablecollection。用戶將通過使用日曆視圖選擇日期。任務<ObservableCollection <AppointmentItem >>不包含的定義其中
public async Task RefreshItems(bool showActivityIndicator, bool syncItems)
{
using (var scope = new ActivityIndicatorScope(syncIndicator, showActivityIndicator))
{
var items = manager.GetAppointmentItemsAsync();
CalendarVM vm = new CalendarVM();
calendar.SetBinding(Calendar.DateCommandProperty, nameof(vm.DateChosen));
calendar.SetBinding(Calendar.SelectedDateProperty, nameof(vm.DateSelected));
calendar.BindingContext = vm;
var filtered = items.Where(appointmentItem => appointmentItem.Date == SelectedDate);
}
}
這是AppointmentPage類中用戶選擇日期和數據的代碼。
public async Task<ObservableCollection<AppointmentItem>> GetAppointmentItemsAsync(bool syncItems = false)
{
try
{
IEnumerable<AppointmentItem> items = await appointmentTable
.ToEnumerableAsync();
return new ObservableCollection<AppointmentItem>(items);
}
catch (MobileServiceInvalidOperationException msioe)
{
Debug.WriteLine(@"Invalid sync operation: {0}", msioe.Message);
}
catch (Exception e)
{
Debug.WriteLine(@"Sync error: {0}", e.Message);
}
return null;
}
這裏是dataManger類的代碼,用於從數據庫中檢索數據。
目前我得到這個錯誤:
Error CS1061 'Task>' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type 'Task>' could be found (are you missing a using directive or an assembly reference?
我也愛你:D –
@glenncooper該死的!我已經回答了太多這樣的問題,沒有人告訴我他們愛我...感覺嫉妒 – CodingYoshi