Los SDK de dispositivos Atlas están obsoletos. Consulte deprecation page for details.
You can read back the data that you have stored in Realm by finding, filtering, and sorting objects.
Read from Realm
You read from a realm with LINQ queries.
Nota
Acerca de los ejemplos de esta página
Los ejemplos de esta página utilizan el modelo de datos de una aplicación de gestión de proyectos que tiene dos tipos de objetos Realm: Project
y Item. Un Project tiene cero o más Items:
public partial class Items : IRealmObject { [] [] public ObjectId Id { get; set; } = ObjectId.GenerateNewId(); public string Name { get; set; } public string Assignee { get; set; } public bool IsComplete { get; set; } public int Priority { get; set; } public int ProgressMinutes { get; set; } } public partial class Project : IRealmObject { [] [] public ObjectId ID { get; set; } = ObjectId.GenerateNewId(); public string Name { get; set; } public IList<Items> Items { get; } }
Query todos los objetos de un determinado tipo
To read all objects of a certain type in a realm, call realm.All<T>, where T is the realm object type. You can then use the returned results collection to further filter and sort the results.
Ejemplo
In order to access all Projects and Items, use the following syntax:
var projects = realm.All<Project>(); var items = realm.All<Items>();
Buscar un objeto específico por clave primaria
Puede encontrar un elemento específico por su clave principal utilizando el Método Find. El siguiente ejemplo busca un solo proyecto:
var myProject = realm.Find<Project>(projectId);