标签:
传统 sql in 写法是 SELECT * FROM dbo.Users s WHERE s.id IN (1,2,3)
在dapper因为安全性,不能直接用sql接接 要采用参数化,
开始我的写法是 _db.Query<Users>("SELECT * FROM dbo.Users s WHERE s.id IN (@id) ",new { id}).ToList(); 一直报错,提示找不到id
经过反复试验确认应该这样写:_db.Query<Users>("SELECT * FROM dbo.Users s WHERE s.id IN (@ids) ",new { ids = IDs.ToArray()}).ToList();
标签:
原文地址:http://www.cnblogs.com/langhua/p/4629401.html