Search code examples
nhibernatecastle-activerecord

Does Castle ActiveRecord supports SQL formula?


Does Castle ActiveRecord supports SQL formula as supported by nHibernate?

E.g. In nHibernate we can do something like this.

<property name="CountOfPosts"
    formula="(select count(*) from Posts where Posts.Id = Id)"/>

Is this supported in Castle Active Record?


Solution

  • Yup, the [Property] attribute has a Formula property.

    [Property(Formula = "(select count(*) from Posts where Posts.Id = Id)")]
    public int CountOfPosts {get;set;}