title: Querying data from multiple tables using Dapper
body: <p>I have the database table <strong>GTL_TITLES</strong> which has two foreign keys, <code>AuthorId</code> and <code>PublisherId</code>. If I want to query a title from the database, I want to also get the information from the <strong>AUTHOR</strong> and <strong>PUBLISHER</strong> tables. For this purpose, I created a stored procedure that joins all three tables and selects the following columns:</p>
  
  <p><a href="https://i.stack.imgur.com/undzS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/undzS.png" alt="enter image description here"></a></p>
  
  <p>My <strong>GtlTitle</strong> Model class looks like this:</p>
  
  <pre><code>public string ISBN { get; set; }
  public string VolumeName { get; set; }
  public string TitleDescription { get; set; }
  public string PublisherName { get; set; }    
  public DateTime PublicationDate { get; set; }
  public Author TitleAuthor { get; set; }
  public Publisher Publisher { get; }
  </code></pre>
  
  <p>As you could have guessed, class <strong>Author</strong> has two strings: <code>FirstName</code> and <code>LastName</code> and <strong>Publisher</strong> has <code>PublisherName</code>.</p>
  
  <p>These being said, this is the method calling the database:</p>
  
  <pre><code>public GtlTitle GetTitle(string ISBN)
      {
          using (var connection = new SqlConnection(_connection))
          {
              connection.Open();
              return connection.QuerySingle&lt;GtlTitle&gt;("GetTitleByISBN", new { ISBN }, commandType: CommandType.StoredProcedure);
          }
      }
  </code></pre>
  
  <p>And returns the following: <code>{"isbn":"978-0-10074-5","volumeName":"Volume Name - 97581","titleDescription":"Description - 97581","publisherName":"Publisher - 714","publicationDate":"2020-05-23T00:00:00","titleAuthor":null,"publisher":null}</code></p>
  
  <p>As you can see, <code>titleAuthor</code> and <code>publisher</code> are null. How can I fix this? Will I need to write fields like <code>public string FirstName</code> in the <strong>GtlTitle</strong> model class instead or is there any way of populating the <strong>Author</strong> and <strong>Publisher</strong>
   as well?</p>