views:

21

answers:

1

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.

+1  A: 

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();
        }
    }
Pedro