我正在使用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;
获得此例外:
对象类型&lt;&gt; 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]]到已知的托管提供者本机类型。
答案 0 :(得分:0)
您正在@0
中将like
与命名参数混合
更改为:
CmsPage.PageTitle LIKE @PageTitle and row > ...