Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 任务<;可观察收集<;任命项目>&燃气轮机;不包含where的定义_C#_Azure_Xamarin_Task_Observablecollection - Fatal编程技术网

C# 任务<;可观察收集<;任命项目>&燃气轮机;不包含where的定义

C# 任务<;可观察收集<;任命项目>&燃气轮机;不包含where的定义,c#,azure,xamarin,task,observablecollection,C#,Azure,Xamarin,Task,Observablecollection,我正在尝试按保存在其中的日期筛选observablecollection。用户将使用日历视图选择日期 public async Task RefreshItems(bool showActivityIndicator, bool syncItems) { using (var scope = new ActivityIndicatorScope(syncIndicator, showActivityIndicator)) {

我正在尝试按保存在其中的日期筛选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;

        }
公共异步任务GetAppointItemsAsync(bool syncItems=false) { 尝试 { IEnumerable items=等待任命表 .ToEnumerableAsync(); 返回新的ObservableCollection(项目); } 捕获(MobileServiceInvalidOperationException msioe) { Debug.WriteLine(@“无效的同步操作:{0}”,msioe.Message); } 捕获(例外e) { Debug.WriteLine(@“同步错误:{0}”,e.Message); } 返回null; } 下面是dataManger类中用于从数据库检索数据的代码

目前我遇到以下错误:

错误CS1061“任务>”不存在 包含“Where”的定义,而不包含扩展方法“Where” 接受类型为的第一个参数 找不到“任务>”(您是吗 缺少using指令或程序集引用

我试着改变

var items = manager.GetAppointmentItemsAsync();


您的以下代码行:

var items = manager.GetAppointmentItemsAsync();
返回一个
任务
,该任务显然不包含
Where
,这就是为什么会出现错误

请将此行更改为:

var items = await manager.GetAppointmentItemsAsync();

然后,您将返回一个类型为
ObservableCollection
的集合,该集合应具有
Where
成员。

:)#WishStackOverflowAllowedSmallerComments。顺便说一句,也给@Alessandro Caliaro一些爱:D。他是第一个回答这个问题的人。@glenncooper该死!我已经回答了这么多的问题,没有人告诉我他们爱我。。。嫉妒
var items = manager.GetAppointmentItemsAsync();
var items = await manager.GetAppointmentItemsAsync();