问题
I am using petapoco. and making search query with like
please let me know there is right query or not?
var context = new PetaPoco.Database(Connection.connectionstring);
SqlQuery =
@"SELECT MenuId, MenuTitle, OrderNumber, CreatedDate, IsActive
from Menu
where MenuTitle LIKE @0, '%@MenuTitle%'";
List<MenuPOCO> objMenuPoco = context.Query<MenuPOCO>
(
SqlQuery,
new
{
@MenuTitle = MenuTitle
}).ToList();
return objMenuPoco;
please let me know the syntax is right? I am getting 0 records in each search.
Regards
回答1:
var context = new PetaPoco.Database(Connection.connectionstring);
SqlQuery =
@"SELECT MenuId, MenuTitle, OrderNumber, CreatedDate, IsActive
from Menu
where MenuTitle LIKE @0";
List<MenuPOCO> objMenuPoco = context.Query<MenuPOCO>(SqlQuery, "%" + MenuTitle + "%").ToList();
return objMenuPoco;
来源:https://stackoverflow.com/questions/18280758/mvc4-petapoco-like-query-throwing-exception