Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I just added a test for this: </p> <pre><code>class Student { public string Name {get; set;} public int Age { get; set; } } public void TestExecuteMultipleCommandStrongType() { connection.Execute("create table #t(Name nvarchar(max), Age int)"); int tally = connection.Execute(@"insert #t (Name,Age) values(@Name, @Age)", new List&lt;Student&gt; { new Student{Age = 1, Name = "sam"}, new Student{Age = 2, Name = "bob"} }); int sum = connection.Query&lt;int&gt;("select sum(Age) from #t drop table #t").First(); tally.IsEqualTo(2); sum.IsEqualTo(3); } </code></pre> <p>It works as advertised. I made a few amendments to the way multi-exec works (so its a tad faster and supports object[]). </p> <p>My guess is you were having issues cause you were missing a getter property on all you fields on <code>WTUser</code>. All params must have reader properties, we do not support pulling this from fields, it would require a complex parsing step to stay efficient. </p> <hr> <p>An additional point that caused an issue is passing dapper a param with unsupported mapping.</p> <p>For example, the following class is not supported as a param: </p> <pre><code>class Test { public int Id { get; set; } public User User {get; set;} } cnn.Query("select * from Tests where Id = @Id", new Test{Id = 1}); // used to go boom </code></pre> <p>The issue is that dapper did <strong>not</strong> parse the SQL, it assumed all the props are settable as params but was unable to resolve the SQL type for <code>User</code>. </p> <p>Latest rev resolves this</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload