开发者

Join tables in NHIbernate

I asked开发者_如何学运维 question in this thread, but nobody answered

NHibernate Map many-to-many join table

how you can select all Persons with phone number contains 777. I do somthing like this, but it does not work

var tags = session.CreateCriteria(typeof(Person))
                .CreateAlias("Phone", "p", JoinType.InnerJoin)
                .CreateAlias("PersonPhone", "pp", JoinType.InnerJoin)
                .Add(Restrictions.Like("p.Name", "777"))
                .List();


        var result = Session.CreateCriteria(typeof (Person))
            .CreateAlias("Phone", "p")
            .Add(Property.ForName("p.Name").Like("777"))
            .List<Person>();

I think this might work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜