此查询的正确语法是什么?
var l=db.Fetch<article>("SELECT * FROM articles WHERE title LIKE '%@0%'", 'something');
或者我应该使用CHARINDEX
?
答案 0 :(得分:28)
可能是
var l=db.Fetch<article>("SELECT * FROM articles WHERE title LIKE @0", "%something%");
答案 1 :(得分:4)
我没试过,但我认为值得尝试:
var l=db.Fetch<article>("SELECT * FROM articles WHERE title LIKE @0", "%" + "something" + "%");
答案 2 :(得分:4)
如果你已经完成了你的映射(T4会为你做什么)那么你可以这样做:
var l=db.Fetch<article>("WHERE title LIKE @0", "%something%");
保存一些输入:)
答案 3 :(得分:0)
也可以尝试这样
var l=db.Fetch<article>("WHERE title LIKE @0", "%" + "something" + "%");
答案 4 :(得分:-2)
Articulo articulo = new Articulo();
articulo = db.SingleOrDefault<Articulo>("SELECT TOP (1) * FROM [Articulos] WHERE [CodigoEmpresa] = @0 and [CodigoArticulo] LIKE @1 ", CodigoEmpresa, codigoArticulo + "%");