-
Type: Task
-
Resolution: Fixed
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
Not sure is it bug or feature but it looks unexpected to me:
Expected Results
Console output:
Kristian[2] 0 = Rex 1 = Тузик
Actual Results
Kristian[3] 0 = Rex 1 = Тузик 1 = Тузик
Code Sample
Unable to find source-code formatter for language: cs. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
public class Person : RealmObject { [PrimaryKey] public int Id { get; set; } public string Name { get; set; } public IList<Dog> Dogs { get; } } public class Dog : RealmObject { [PrimaryKey] public int Id { get; set; } public string Name { get; set; } }
and usage:
Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
var realm = Realm.GetInstance(); realm.Write(() => realm.RemoveAll()); var dog1 = new Dog { Id = 0, Name = "Rex" }; var dog2 = new Dog { Id = 1, Name = "Bethoven" }; Person k = new Person { Id = 1, Name = "Kristian", Dogs = { dog1, dog2 } }; realm.Write(() => realm.Add(k)); var dog3 = new Dog { Id = 1, Name = "Тузик" }; realm.Write(() => { realm.Add(dog3, true); k.Dogs.Add(dog3); }); Console.WriteLine($"{k.Name}[{k.Dogs.Count}]"); foreach (var dog in k.Dogs) Console.WriteLine($"{dog.Id} = {dog.Name}");
Version of Realm and Tooling
Realm: 4.2.0
Related:
If one adds the same object to the inner collection then count of objects will be increases as well.