简体   繁体   中英

Dapper - like operator using DynamicParameters

This works:

var list = conn.Query<int>(
  "select Id from Person where Id in @ids", 
  new { ids = new int[] { 1, 2, 3 } }
);

This throws "No mapping exists from object type System.Int32[] to a known managed provider native type.":

DynamicParameters parameters = new DynamicParameters(
  new { ids = new int[] { 1, 2, 3 } }
);
var list2 = conn.Query<int>(
  "select Id from Person where Id in @ids", 
  parameters
);

Any ideas?

Just fixed this issue in the latest dapper (grab from hg), the code used to diverge around the DynamicParameters value extraction. Now the code being run is the same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM