Given two Realm classes
public class Note : EmbeddedObject
{
[MapTo("_id")]
public ObjectId Id { get; set; } = ObjectId.GenerateNewId();
[MapTo("title")]
public String Title { get; set; }
};
public class SharedWith : RealmObject
{
[PrimaryKey]
[MapTo("_id")]
public ObjectId Id { get; set; } = ObjectId.GenerateNewId();
[MapTo("ownerId")]
public ObjectId OwnerId { get; set; }
[MapTo("recipientId")]
public ObjectId RecipientId { get; set; }
[MapTo("notes")]
public IList<Note> Notes { get; }
};
How do I get a list from Realm realm of all the Note objects embedded within a set of SharedWith objects?
I can get the SharedWith objects with a query such as
_realm.All<SharedWith>().Where(sw => sw.RecipientId == p.Id)
I want to have a flattened IEnumerable<Appointment>
I can bind to a Xamarin CollectionView
I’m using a rather horrible instantion of all objects.
var myShared = _realm.All<SharedWith>().Where(sw => sw.RecipientId == p.Id);
var instNotes = new List<Note>();
foreach (var sw in myShared) {
instNotes.AddRange(sw.Notes);
}
Notes = instNotes;