protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); DocumentMapping.Map(modelBuilder.Entity <Document>()); DocumentTypeMapping.Map(modelBuilder.Entity <DocumentType>()); }
public async Task <List <DocumentDto> > GetDocuments() { var documents = await _context.Documents .OrderBy(n => n.Name) .ToListAsync(); var documentMapping = new DocumentMapping(); var documentDtos = new List <DocumentDto>(); foreach (var document in documents) { documentDtos.Add(documentMapping.Map(document)); } //returns an empty list when nothing is found. return(documentDtos); }