views:

43

answers:

0

Hi,

I have been playing around with the AbstractSearchFilter featured in Ayende blog here. The idea is you abstract the query building for search to the UI. While I can see how it works for simplistic restriction queries I am struggling to see how this could be used for something such as subqueries on ID, which are very comment in my app, for example something like:

var commentIds = DetachedCriteria.For(typeof(Post), "p")
                                      .CreateCriteria("Comments", "c")
                                      .SetProjection(Projections.Property("c.Id"))
                                      .Add(Restrictions.Eq("p.Id", postId));

var comments = DetachedCriteria.For(typeof(Comment))
            .Add(Subqueries.PropertyIn("Id", commentIds));

return GetPagedData<Comment>(page, numPerPage, comments);

This doesn't seem to fit very well with the pattern.

I'm interested in different approaches to this, has anyone else used the above technique, if so was it successful. Any useful blog posts I may have missed?

Thanks