【发布时间】:2017-04-22 12:36:49
【问题描述】:
我正在尝试按保存在其中的日期过滤 observablecollection。用户将使用日历视图选择日期。
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 类中用于从数据库中检索数据的代码。
目前我收到此错误:
错误 CS1061 'Task>' 没有 包含“Where”的定义并且没有扩展方法“Where” 接受类型的第一个参数 'Task>' 可以找到(你是 缺少 using 指令或程序集引用?
【问题讨论】:
标签: c# azure xamarin task observablecollection