用Fluent NHibernate查询属性 [英] Query-only properties with Fluent NHibernate

查看:103
本文介绍了用Fluent NHibernate查询属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到如何在 Ayende的博客与Fluent NHibernate一起工作。

据我所知,我可以映射伪字段,哪个值是任何hql的结果查询。它是否正确?如何使用Fluent Nhibernate这个功能?我试过谷歌,但不成功。代码示例或链接到他们将不胜感激。

解决方案

根据这个票证它的作品:

http://code.google .com / p / fluent-nhibernate / issues / detail?id = 259

有一个示例,但是我没有测试过。 / p>

Ayende的例子的结果很可能就像下面这样。请注意,显然不能避免拥有表示集合的属性。

  public class BlogMap:ClassMap< Blog> 
{
public BlogMap()
{
Id(p => p.Id);
Map(p => p.Title
HasMany(p => p.Posts).AsSet()
.Where((PostedAt> =(getdate() - 30 )))
.Access.NoOp();
}
}


I can't find how Nhibernate feature described in Ayende's blog works with Fluent NHibernate.

As far as I understand, I can map pseudo-field which value is a result of any hql query. Is this correct? How this feature can be used with Fluent Nhibernate? I tried google, but unsuccessful. Code samples or links to them would be much appreciated.

解决方案

According to this ticket it works:

http://code.google.com/p/fluent-nhibernate/issues/detail?id=259

There is a sample there, but I haven't tested it.

The result with Ayende's example would probaly be something like below. Note that aparently it can't be avoided to have the property representing the collection.

    public class BlogMap : ClassMap<Blog>
    {
        public BlogMap()
        {
            Id(p => p.Id);
            Map(p => p.Title
            HasMany(p => p.Posts).AsSet()
                .Where("(PostedAt >= (getdate() - 30) )")
                .Access.NoOp();
        }
    }

这篇关于用Fluent NHibernate查询属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆