Witam serdecznie. Ostatnio chodzi mi po głowie: Jak mam dwa modele:
public class Library
{
public Guid Id { get; set; }
public string Name { get; set; }
public virtual List<Book> NotAssocciatedBooks { get; set; }
public virtual List<Book> AssocciatedBooks { get; set; }
}
public class Book
{
public Guid Id { get; set; }
public string Name { get; set; }
public Guid LibraryId { get; set; }
public virtual Library Library { get; set; }
public string AssociatedUserId { get; set; }
public ApplicationUser AssociatedUser { get; set; }
}
To jest możliwe, aby NotAssocciatedBooks
wybierały książki z danej biblioteki których użytkownik jest równy null
a
AssocciatedBooks
wybierały książki z danej biblioteki których użytkownik nie jest równy null
? Chodzi mi wtedy o proste wywołanie:
var library = await _dbContext.Include(x => x.AssocciatedBooks).FirstOrDefaultAsync(x => x.Id == id);
var libraryDto = new LibraryDto()
{
library = library,
associatedBooksCount = library.AssocciatedBooks.count()
}