0

I am using Micro ORM PetaPOCO, and I want to use like query, i am getting exception, please help me if any one know.

var context = new PetaPoco.Database(Connection.connectionstring);
            SqlQuery = @"SELECT CmsPage.PageId, CmsPage.PageTitle, CmsPage.MenuId, CmsPage.PageDescription, CmsPage.Title, CmsPage.MetaKeyword, CmsPage.MetaDescription, CmsPage.CreatedDate, CmsPage.IsActive
            FROM ( SELECT ROW_NUMBER() OVER (ORDER BY CmsPage.PageTitle) AS row, CmsPage.PageId, CmsPage.PageTitle, CmsPage.MenuId, CmsPage.PageDescription,
            CmsPage.Title, CmsPage.MetaKeyword, CmsPage.MetaDescription, CmsPage.CreatedDate, CmsPage.IsActive FROM CmsPage ) AS CmsPage WHERE
            CmsPage.PageTitle LIKE @0 and row > ((@CurrPage - 1) * @PageSize)  and  row <= (@CurrPage * @PageSize)";


            List<CmsPagePOCO> obCmsPagePOco = context.Query<CmsPagePOCO>(
                SqlQuery, 
                    new 
                    {
                        @CurrPage = CurrPage,
                        @PageSize = PageSize,
                        @PageTitle = "%" + PageTitle + "%"

                    }).ToList();

            return obCmsPagePOco;

getting this exception :

No mapping exists from object type <>f__AnonymousType1`3[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] to a known managed provider native type.

dotnetexpert
  • 145
  • 2
  • 16

1 Answers1

0

You are mixing @0 in the like with named parameters

change to:

CmsPage.PageTitle LIKE @PageTitle and row > ...
Eduardo Molteni
  • 38,786
  • 23
  • 141
  • 206
  • yes, i have done already, you are also right so accepting this answer :) I have another issue, if you have any idea please visit : http://stackoverflow.com/questions/18412562/web-api-400-badrequest-when-search-parameter-is-blank/18412781?noredirect=1#comment27048785_18412781 – dotnetexpert Aug 23 '13 at 23:15