Partial upsert?
#3706
-
|
Am curious if there's a way to way to only partially upsert a realm object. Given the class: public partial class MyObject : IRealmObject
{
[PrimaryKey]
public int Id { get; set; }
public int Count { get; set; }
public bool SomeLocalState { get; set; }
}And the operation: MyObject first = new() { Id = 1, Count = 0, SomeLocalState = true };
realm.Write(() => realm.Add(first));
MyObject second = new() { Id = 1, Count = 4, SomeLocalState = false };
realm.Write(() => realm.Add(second, update: true));Does realm have a built-in way for me to say that My use case is that we're downloading information from a server and I would like to save some amount of state to an object that has no meaning outside of our app. |
Beta Was this translation helpful? Give feedback.
Answered by
nirinchev
Jul 17, 2025
Replies: 1 comment 3 replies
-
|
I haven't tested, but have you attempted adding the realm |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could also use automapper or a similar library and define a mapping rule that sets only a subset of all properties. Then, instead of doing an upsert, you'd need to lookup the existing object and map on top of it. In pseudocode, would look something like: