开发者

How do I phrase this query in NHibernate with Lambda Extensions?

I'm using NHibernate with Lambda Extensions and I can't figure out how to phrase a specific kind of query.

My application lets users tag other users in pictures. So there are Picture objects, a开发者_StackOverflow中文版nd each Picture has one or more Tag objects, and each Tag object has one User object.

I'm implementing a search feature. Given a search string, I want to return all Pictures whose Name contains the string or which have any Tags with a User whose Name contains the string.

I don't know how to assemble this query, or whether I need to do it with subqueries or aliases. What would be the proper way to do this?


In Lamdba I don't know but you can use alias to search on the collection ?

session.CreateCriteria<Picture>()
    .CreateAlias("Tags", "tags")
    .Add(
    Expression.Or(
        Expression.Eq("Name","term"),
        Expression.Eq("tags.User.Name","term")));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜