以上的语句执行后的结果是错误的,在Dapper中,类似SQL语句中的like应该如何处理呢?
方案一
term = "whateverterm";
var encodeForLike = term => term.Replace("[", "[[]").Replace("%", "[%]");
string term = "%" + encodeForLike(term) + "%";
var data = conn.Query(@"
select top 25
Term as Label,
Type,
ID
from SearchTerms
WHERE Term like @term",
new { term });
方案二
string query = "SELECT * from country WHERE Name LIKE CONCAT(‘%‘,@name,‘%‘);"
var results = connection.query<country>(query, new {name});
方案三
db.Query<Remitente>("SELECT *
FROM Remitentes
WHERE Nombre LIKE @n", new { n = "%" + nombre + "%" })
.ToList();Sqlite 参数化 模糊查询 解决方案
标签:nec 模糊 csharp rms result 描述 select tps head
本文系统来源:https://www.cnblogs.com/wanglg/p/9851273.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!