2015-12-20 29 views
1

我想要从Azure获取数据。这是我的代码:从移动服务获取数据表

private async void FindPromotion() 
    { 
     MobileServiceCollection<Promotions, Promotions> result; 
     MobileServiceInvalidOperationException exception = null; 

     string _place = textInputPlace.Text; 

     if (_place!= null) 
     { 
      try 
      { 
       //lista obiektów Category 
       result = await todoTable2.Where(todoItem => todoItem.Place==_place) 
        .Select(todoItem => todoItem.Products, todoItem => todoItem.Description) 
        .ToCollectionAsync();     

      } 
      catch (MobileServiceInvalidOperationException ex) 
      { 
       exception = ex; 
      } 

      if (exception != null) 
      { 
       await new MessageDialog(exception.Message, "Can't find items").ShowAsync(); 
      } 
      else 
      { 
       ListItems.ItemsSource = result.Distinct(); 
      } 

     } 
    } 

我有错误:

没有重载方法“选择”需要两个参数。

有人知道吗?另一种获得这些数据的方法是什么?

回答

1

这是你可以选择多列:

result = await todoTable2.Select(todoItem => new { todoItem.Products , todoItem.Description}).ToCollectionAsync(); 
+0

谢谢:)我怎样才能获得字符串类型和DATETIMEOFFSET在对象的结果?当我想这样做,我有错误:不能隐式转换类型MobileServiceCollection 到'Microsoft.WindowsAzure.MobileServices.MobileServiceCollection <字符串,字符串> – mady808

+0

你好,你可以问另一个问题或更新与您所做的更改不起作用?谢谢 – Aram