title: Can I Use Query Method in Dapper To Insert And Update Rows?
body: <p>I'm trying to find out whether it is possible to use Query method in Dapper to insert and update rows since I want to return an object after applying insert and update actions.</p>
  <p>I could not find any remarkable answers for that so I just tried that:</p>
  <pre><code>public async Task&lt;Hotel&gt; CreateHotel(Hotel hotel)
      {
          var sql = &quot;INSERT INTO Hotels&quot; +
                      &quot; (name, city)&quot; +
                      &quot; VALUES (@name, @city)&quot;;
  
          var newHotel = new Hotel()
          {
              Name = hotel.Name,
              City = hotel.City
          };
  
          using (var connection = new SqlConnection(CONNECTION_STRING))
          {
              return (Hotel)await connection.QueryAsync&lt;Hotel&gt;(sql, newHotel);
          }
      }
  </code></pre>
  <p>But that gives that error: <em>System.InvalidCastException: Unable to cast object of type 'System.Linq.EmptyPartition<code>1[HotelFinder.Entities.Hotel]' to type 'System.Collections.Generic.List</code>1[HotelFinder.Entities.Hotel]'.</em></p>
  <p>Do you know how I can fix this or is that completely wrong?</p>