地图POCO像查询问题 [英] Peta POCO like query issue
问题描述
我使用的微型ORM PetaPOCO,我想用这样的查询,我得到的异常,请帮助我,如果有任何人知道。
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;
得到此异常:
没有映射从对象的类型&lt存在;> f__AnonymousType1`3 [System.Int32,mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089],[System.Int32,mscorlib程序,版本= 4.0.0.0文化=中性公钥= b77a5c561934e089],[System.String,mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089]]到一个已知的托管提供原始类型。
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.
推荐答案
您在混合 @ 0
在像
与命名参数
更改为:
CmsPage.PageTitle LIKE @PageTitle and row > ...
这篇关于地图POCO像查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!