Reputation: 7304
I’ve had a sync operation in place in my Xamarin Forms app for a long time now and only this pase couple of weeks has it started throwing exceptions, which makes me think maybe it’s a service change or something introduced in an update? On startup I sync all data with m Azure Mobile Service using:
await this.client.SyncContext.PushAsync();
if (signedInUser != Guid.Empty)
{
await this.MyTable.PullAsync(
"myWorkoutsOnly",
this.MyTable.CreateQuery().Select(u => u.UserId == signedInUser));
}
And as I say, I’ve never had an issue with this code. Now though, I’m getting:
System.ArgumentException: Pull query with select clause is not supported
I only want to sync the data that matches the signed in user, so is there another way to achieve this?
Upvotes: 1
Views: 89
Reputation: 18465
I only want to sync the data that matches the signed in user, so is there another way to achieve this?
You could leverage the code below to achieve your purpose as follows:
var queryName = $"incsync_{UserId}";
var query = table.CreateQuery()
.Where(u => u.UserId == signedInUser);
await table.PullAsync(queryName, query);
For Select
method, you could retrieve the specific properties into your local store instead of all properties in your online table as follows:
var queryName = $"incsync:s:{typeof(T).Name}";
var query = table.CreateQuery()
.Select(r => new { r.Text, r.Complete, r.UpdatedAt, r.Version });
await table.PullAsync(queryName, query);
For more details, you could refer to adrian hall's book about Query Management.
UPDATE:
As Joagwa commented, you could change your server side code and limit data to be retrieved only by the logged in user. For more details, you could refer to Data Projection and Queries > Per-User Data.
Upvotes: 2