Don't dispose fetched realm instance when using `RealmLive.Value`

See https://github.com/realm/realm-dotnet/discussions/2734#discussioncomment-1705038 for reasoning.
This commit is contained in:
Dean Herbert 2021-11-26 21:33:11 +09:00
parent 1dd5e1ca89
commit 348d1d0be9
1 changed files with 4 additions and 3 deletions

View File

@ -100,10 +100,11 @@ public T Value
if (originalDataValid)
return data;
T retrieved;
if (!isCorrectThread)
throw new InvalidOperationException($"Can't use {nameof(Value)} unless on the same thread the original data was fetched from.");
using (var realm = Realm.GetInstance(data.Realm.Config))
retrieved = realm.Find<T>(ID);
var realm = Realm.GetInstance(data.Realm.Config);
var retrieved = realm.Find<T>(ID);
if (!retrieved.IsValid)
throw new InvalidOperationException("Attempted to access value without an open context");