Pregunta

What is the correct syntax for this query?

var l=db.Fetch<article>("SELECT * FROM articles WHERE title LIKE '%@0%'", 'something');

Or should I use CHARINDEX?

¿Fue útil?

Solución

May be

var l=db.Fetch<article>("SELECT * FROM articles WHERE title LIKE @0", "%something%");

Otros consejos

I haven't tried this, but I think it is worth trying:

var l=db.Fetch<article>("SELECT * FROM articles WHERE title LIKE @0", "%" + "something" + "%");

If you have done your mappings (wich the T4 will do for you) then you could infact do it like so:

var l=db.Fetch<article>("WHERE title LIKE @0", "%something%");

Saves some typing :)

Can try like this also

var l=db.Fetch<article>("WHERE title LIKE @0", "%" + "something" + "%");
Articulo articulo = new Articulo();

articulo = db.SingleOrDefault<Articulo>("SELECT TOP (1) * FROM [Articulos] WHERE [CodigoEmpresa] = @0 and [CodigoArticulo] LIKE @1 ", CodigoEmpresa, codigoArticulo + "%");
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top