I have an Embedded Model:
public class Address: EmbeddedObject
{
public string Locality { get; set; }
public string Pin { get; set; }
public string PostOffice { get; set; }
public string District { get; set; }
public string City { get; set; }
public string State { get; set; }
}
Another RealmObject Model Which have Address Model as a Property:
public class MilkMan : RealmObject
{
[PrimaryKey]
[MapTo(“_partition”)]
public ObjectId MilkManId { get; set; } = ObjectId.GenerateNewId();
public string PreferredLanguage { get; set; } = “English”;
public string Name { get; set; }
public DateTimeOffset DateOfBirth { get; set; }
public string Sex { get; set; } = “Male”;
public Address Address { get; set; }
public IList Incomes { get; set; }
}
Than I initialize the MilkMan Model like this :
MilkManProfile = realm.All().FirstOrDefault();
if (MilkManProfile == null)
{
MilkManProfile = realm.Write(() =>
{
var address = new Address();
var profile = new MilkMan (){ Address=address};
// set properties if necessary
return realm.Add(profile);
});
}
The issue is that Address property of the MilkManProfile remain null even after initializing it.