开发者

Query-only properties with Fluent NHibernate

I can't find how Nhibernate feature described in A开发者_运维知识库yende'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();
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜