Microsoft.Datasync.Client.IOfflineTable - 'Contains' is not supported in a 'Where' clause #683
-
public async Task<IEnumerable<HZP_Storage_Unit_Pending>> GetPendingUnitsBySalesOrderNos(List<string> salesOrderNumbers)
{
List<HZP_Storage_Unit_Pending> storageUnitsPending = new List<HZP_Storage_Unit_Pending>();
if (salesOrderNumbers != null || salesOrderNumbers.Count() > 0)
{
storageUnitsPending = await Table.Where(c => salesOrderNumbers.Contains(c.HZ_SalesOrderNo)).ToListAsync();
}
return storageUnitsPending;
} In the code above, the line storageUnitsPending = await Table.Where(c => salesOrderNumbers.Contains(c.HZ_SalesOrderNo)).ToListAsync(); works against Microsoft.WindowsAzure.MobileServices.Sync.IMobileServiceSyncTable. However, against Microsoft.Datasync.Client.IOfflineTable, it throws the following error: To get it to work, I've rewritten the code as follows: public async Task<IEnumerable<HZP_Storage_Unit_Pending>> GetPendingUnitsBySalesOrderNos(List<string> salesOrderNumbers)
{
List<HZP_Storage_Unit_Pending> storageUnitsPending = new List<HZP_Storage_Unit_Pending>();
if (salesOrderNumbers != null || salesOrderNumbers.Count() > 0)
{
storageUnitsPending = (await Table.ToListAsync()).Where(c => salesOrderNumbers.Contains(c.HZ_SalesOrderNo)).ToList();
}
return storageUnitsPending;
} The problem with this rewrite is that it results in very poor performance. Is there a better way of doing this? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Nope - we don't support lists in the SQL statement. The LINQ variant is a restricted set of methods that the OData backend understands. |
Beta Was this translation helpful? Give feedback.
-
Hey @adrianhall! Is there still no good way to select, e.g., by multiple ids from the offline table? |
Beta Was this translation helpful? Give feedback.
Nope - we don't support lists in the SQL statement. The LINQ variant is a restricted set of methods that the OData backend understands.