0

我正在使用 Micro ORM PetaPOCO,我想使用类似查询,我遇到异常,如果有人知道,请帮助我。

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;

得到这个例外:

对象类型 <>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]] 到已知的托管提供程序本机类型。

4

1 回答 1

0

您正在@0like命名参数混合

改成:

CmsPage.PageTitle LIKE @PageTitle and row > ...
于 2013-08-23T13:32:28.840 回答