【问题标题】:Error when using AliasToBeanResultTransformer in Criterion在 Criterion 中使用 AliasToBeanResultTransformer 时出错
【发布时间】:2011-05-13 20:11:37
【问题描述】:

我正在尝试进行一些分页和一些获取,但结果返回重复项。因此,我添加了 AliasToBeanResultTransformer,但随后出现以下错误:

在“ForumThread”类中找不到属性“this”的设置器

var crit = Session.CreateCriteria<ForumThread>()
                .Add(Expression.Eq("IsActive", true))
                .AddOrder(new Order("LastForumPost", false))
                .SetFirstResult((page - 1)*pageSize)
                .SetMaxResults(pageSize)
                .SetFetchMode("ForumPosts", FetchMode.Eager)
                .SetFetchMode("ForumTagRelations", FetchMode.Eager)
                .SetCacheable(true)
                .SetResultTransformer(new NHibernate.Transform.AliasToBeanResultTransformer(typeof (ForumThread)));
return crit.List<ForumThread>();

我可能缺少什么?

【问题讨论】:

  • 我通过不使用该转换器解决了这个问题。我根本没有设置它,它只是有点工作。 :\

标签: nhibernate-criteria


【解决方案1】:

为避免重复,您需要使用DistinctRootEntityResultTransformer,而不是AliasToBeanResultTransformer

【讨论】:

    猜你喜欢
    • 2011-08-31
    • 1970-01-01
    • 2013-02-11
    • 1970-01-01
    • 1970-01-01
    • 2018-06-14
    • 2012-04-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多