0

使用此代码:

public static async Task<List<DUCKBILLED_PLATYPI>> GetLocationsForPlatypiAndTimeRange(HashSet<string> PlatypiIds, DateTime EarliestToShow, DateTime LatestToShow)
{
    List<DUCKBILLED_PLATYPI> listLocs = new List<DUCKBILLED_PLATYPI>();
    List<string> PlatypusBillIDList;
    string PlatypusBillID; 
    IMobileServiceTable<DUCKBILLED_PLATYPI> table = App.MobileService.GetTable<DUCKBILLED_PLATYPI>();
    MobileServiceTableQuery<DUCKBILLED_PLATYPI> query;

    foreach (var item in PlatypiIds)
    {
            PlatypusBillIDList = await GetPlatypusBillIDForPlatypusID(item);
    PlatypusBillID = PlatypusBillIDList[0];
    query = 
        table.Where(l => l.PlatypusBillID == PlatypusBillID).
              Where(l => l.UpdateTimeUTC >= EarliestToShow).
              Where(l => l.UpdateTimeUTC <= LatestToShow).
              OrderBy(l => l.UpdateTimeUTC);
    listLocs.Add(query);
    }
    return listLocs;
}

...我在同一行收到两条错误消息(“ listLocs.Add(query); ”行);他们是:

1) Error    1   The best overloaded method match for 'System.Collections.Generic.List<MetroSandboxPlaypen.TaSLs_Data.DUCKBILLED_PLATYPI>.Add(MetroSandboxPlaypen.TaSLs_Data.DUCKBILLED_PLATYPI)' has some invalid arguments
2) Error    2   Argument 1: cannot convert from 'Microsoft.WindowsAzure.MobileServices.MobileServiceTableQuery<MetroSandboxPlaypen.TaSLs_Data.DUCKBILLED_PLATYPI>' to 'MetroSandboxPlaypen.TaSLs_Data.DUCKBILLED_PLATYPI'
4

1 回答 1

1

您还没有执行查询;您需要实现它:await query.ToListAsyncawait query.ToEnumerableAsync。您还需要使用listLocs.AddRangeAdd,因为您可能会返回 0、1 或多行。

另一方面,您期望有多少项目PlatypiIds?您的循环看起来对每个项目至少进行两次服务调用,因此您可能想要测试聊天是否对最终用户体验产生影响,而是尝试通过一两个查询来获取所有数据。

于 2012-12-15T01:24:14.363 回答