-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to save extra properties in offline db which are not exists in remote table #258
Comments
There are two methods that you can use:
Of the two, (2) is preferred since it ensures that you can reset the table without destroying the local only data. In production, table resets are not unknown as a fix to missing data that can't be re-created except through a re-synchronization event. |
@adrianhall Thanks for your response. For the first case, the property is simply ignored and is not being saved in the local database. I will try to implement the second approach. However, with the old SDK (https://github.com/Azure/azure-mobile-apps), it used to save local-only properties in the local database along with remote properties without requiring a separate table |
For the first case, - I think there is something else going on here. JsonIgnore does not affect what is happening via EF Core. It only affects serialization. Thus, it should not be ignored by EF Core. I've got explicit tests for this case, so there is something else happening with your code. |
Hey @adrianhall, JsonIgnore works fine until we explicitly call PushAsync. However, the marked JsonIgnore property values reset when calling PullAsync after PushAsync Here is sample code public async Task SaveItemAsync(T item, CancellationToken token = default(CancellationToken))
{
try
{
using (var dbContext = new AppDbContext(dbContextOptionsBuilder.Options))
{
dbContext.TokenRequester = TokenRequester;
await ClearExistingQueue(dbContext, typeof(T));
if (item == null)
{
throw new ArgumentException(nameof(item));
}
ListAction action = (item.Id == null) ? ListAction.Add : ListAction.Update;
if (item.Id == null)
{
item.Id = Guid.NewGuid().ToString("N");
await dbContext.Set<T>().AddAsync(item, token);
}
else
{
dbContext.Set<T>().Update(item);
}
await dbContext.SaveChangesAsync();
await dbContext.Set<T>().PushAsync();
}
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
//ItemsUpdated?.Invoke(this, new RemoteServiceEventArgs<T>(action, item));
} |
@adrianhall and one more thing CommunityToolkit.Datasync.Client ignores nested models and returns null values. Where as it used work Microsoft.Datasync.Client (https://github.com/Azure/azure-mobile-apps). |
Microsoft.Datasync.Client never supported nested models. They worked by accident. Because of the move to EF Core for database access (instead of a direct SQlite system), we're explicitly not supporting nested models. The lack of support has been in the documentation for as long as I was managing Azure Mobile Apps (going on a decade now). I'll work up a design for properly ignoring model properties. |
@adrianhall Any update on this ? |
I’ve validated the request, and tagged it into a release. There will be no update until that release is done. |
I've integrated the Community data sync client into our .NET MAUI app, and everything is functioning well. However, I'm encountering an issue with the offline sync table. Specifically, in the attached ConstructionDto file, I've added a new property that should be retained only in the offline table and not synced with the remote table. Is this possible? If so, could you please provide a solution?
FYI: This was working fine with old sdk. Reference link : https://github.com/Azure/azure-mobile-apps
Server:
Client:
Do let me know if you require any additional details
Regrads,
Sateesh taddi.
The text was updated successfully, but these errors were encountered: