Я пытаюсь ограничить данные, возвращаемые службой мобильных приложений, размещенной на портале Azure. К сожалению, я не могу ограничить данные до их возвращения (на этапе createQuery ()). Фильтр работает только при применении после возврата данных. Вот пример кода. Приложение написано в формах Xamarin на платформе iOS.
public async Task<IEnumerable<Company>> GetCompanies(string
cityId)
{
await App.MobileService.SyncContext.InitializeAsync(store,
handler);
this.companies = App.MobileService.GetSyncTable<Company>();
try
{
await App.MobileService.SyncContext.PushAsync();
// Filter is unsuccessful here
await this.companies.PullAsync("all_companies",
this.companies.CreateQuery().Where(x => x.City_Id ==
cityId)).ConfigureAwait(false);
}
catch (MobileServicePushFailedException ex)
{
string ErrorString = string.Format("Push failed because
of Company sync errors: {0} errors, message:
{1}",ex.PushResult.Errors.Count, ex.Message);
}
catch (Exception ex)
{
Debug.WriteLine("Exception Sync companies: " + ex);
}
// Filter works here. But its too late as it has already
// pulled all the unnecessary data
return await companies.Where(x => x.City_Id ==
cityId).OrderBy(c => c.Id).ToEnumerableAsync();
}