Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

What is the proper way to structure DTO's for my tables?

Three of my tables are Documents which contains Pages and Fontstyles. I am creating an EditDocument view in which I will edit these (and more) tables related to document.

I thought of a solution, but I'm not sure if this is the proper way to do it. I'm just a beginner and just starting with dependency injection so, I might need some help on that too. what are your thoughts?

Create a List< fontStyleDTO > and List< PagesDTO > within DocumentDTO which contains the pages and fonts

public class DocumentDTO
    public DocumentDTO (List<FontStyleDTO> fontStyles, List<PageDTO> pages) {
        _fontStyles = fontStyles;
        _pages = pages;

    public List<FontStyleDTO> Pages {
        get { return _pages; }

    public List<PageDTO> FontStyles {
        get { return _fontStyles; }

If I would want to add a page to the document I would do:


And then via the OR-mapper in the database:

public class DocumentDTOIntoDatabase

    public DocumentDTOToDatabase (DTODocument document, DocumentMapper documentMapper) {
       _document = document;
       _documentMapper = documentMapper;

    public AddDocumentToDatabase() {
        Document ormDocument = _documentMapper.FindById(document.id)
        ormDocument.name = document.name;
        AddPagesToDocument(document.pages, ormDocument)

    public AddPagesToDocument(List<PageDTO> pages, Document ormDocument) {
        foreach (var page in document.Pages) {                
share|improve this question

migrated from programmers.stackexchange.com Feb 21 '13 at 17:12

This question came from our site for professional programmers interested in conceptual questions about software development.

What do you mean by "proper?" What you have there looks like it will work to me. –  Robert Harvey Feb 20 '13 at 18:07
I mean according to best practices. –  user4856 Feb 21 '13 at 8:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.