x__dos
x__dos

Reputation: 1823

Query-only properties with Fluent NHibernate

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.

Upvotes: 2

Views: 980

Answers (1)

Pedro
Pedro

Reputation: 11894

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

Upvotes: 3

Related Questions