Как выбрать отношение «один ко многим» и один к одному вместе с помощью dapper

У меня есть следующие классы и схема БД. Я пытаюсь запросить эти данные из базы данных с помощью dapper, который бы гидратировал полный граф объекта. Я просмотрел различные вопросы SO и тест, но не мог понять, как это сделать.

Схема БД

Author
  -AuthorId
  -Name

Post
  -PostId
  -Content
  -AuthorId

Comment
  -PostId
  -CommentId
  -Content

Tag
  -PostId
  -TagId
  -Name

Классы

public class Author
{
    public int AuthorId { get; set; }
    public string Name { get; set; }
}

public class Tag
{
    public int PostId { get; set; }
    public int TagId { get; set; }
    public string Name { get; set; }
}

public class Post
{
    public int PostId { get; set; }
    public string Content { get; set; }
    public int AuthorId { get; set; }
    public List<Tag> Tags { get; set; }
    public List<Comment> Comments { get; set; }
    public Author Author { get; set; }

    public Post()
    {
        this.Comments = new List<Comment>();
        this.Tags = new List<Tag>();
    }
}

public class Comment
{
    public int PostId { get; set; }
    public int CommentId { get; set; }
    public string Content { get; set; }
}
5
задан Anil Ali 1 August 2011 в 04:43
поделиться