title: Using Dapper to map to nested objects not working
body: <p><strong>The Problem</strong></p>
  
  <p>Simply put, the mapping does not perform as expected. The local variable <code>reason</code> comes back as null so the assignment to <code>nav</code> sets the nested object <code>Reason</code> to null as well. </p>
  
  <p>Am I missing something simple here? </p>
  
  <p><strong>The Stored Procedure</strong></p>
  
  <pre><code>ALTER PROCEDURE [PA].[spGetDocumentNavById]
  -- Add the parameters for the stored procedure here
  @DocumentNavID INT
  AS
  BEGIN
  -- SET NOCOUNT ON added to prevent extra result sets from
  -- interfering with SELECT statements.
  SET NOCOUNT ON;
  
  -- Insert statements for procedure here
  SELECT
      dn.DocumentNavID,
      dn.IssuerName,
      nt.Name,
      dn.Amount,
      dn.BTF,
      dn.NavDate,
      dn.ReceivedDate,
      dn.PrimaryIdentifier,
      dn.AssetID,
      dh.LastModifiedBy,
      dh.IsApproved,
      dh.Corrected,
      dh.ReasonID
  FROM PA.DocumentNavs dn WITH(NOLOCK)
      JOIN PA.NAVTypes nt WITH(NOLOCK)
          ON nt.NAVTypeID = dn.NavTypeID
      LEFT JOIN PA.DocumentsHistory dh WITH(NOLOCK)
          ON dh.DocumentID = dn.DocumentID
      LEFT JOIN PA.Analysts a WITH(NOLOCK)
          ON a.AnalystID = dh.LastModifiedBy
  WHERE dn.DocumentNavID = @DocumentNavID
  </code></pre>
  
  <p><strong>The C#</strong></p>
  
  <pre><code>public DocumentNav FindById(int documentNavId)
      {
          var data = new
          {
              documentNavId
          };
  
          using (var conn = SqlConnection)
          {
              var response = conn.Query&lt;DocumentNav, Reason, DocumentNav&gt;("[PA].spGetDocumentNavById",
                  map: (nav, reason) =&gt;
                  {
                      nav.Reason = reason;
                      return nav;
                  }, param: data, splitOn: "ReasonID", commandType: System.Data.CommandType.StoredProcedure)
                  .DefaultIfEmpty().FirstOrDefault();
  
              return response;
          }
      }
  </code></pre>