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.
精彩评论