mvc4 PetaPoco like query throwing exception

穿精又带淫゛_ 提交于 2019-12-12 03:15:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!