Say, that I have the following entities defined:
public class User : IdentityUser
{
public virtual string Name { get; set; }
public virtual string Surname { get; set; }
public virtual List<Entry> Entries { get; set; }
}
public class Entry
{
[Key]
public virtual int Id { get; set; }
public virtual string UserId { get; set; }
public virtual User User { get; set; }
public virtual long Timestamp { get; set; }
public virtual string Comment { get; set; }
}
I'd like to retrieve:
- A list of all users
- With a list of entries for each user (with empty list if the user has no entries)
- With entries' Timestamp being between values X and Y
Obviously I can dump Users and Entries tables and organize data by myself, but that would be very inefficient. Is there a way to generate such a result with Entity Framework query?