귀하의 구문을 확인하고, 단지 몇 가지 변경 또는 개선은 여기에 ... 수행 할 수 있습니다
IList<Department> departments;
var parents = new List<int> {167};
// advantage of this "original" QueryOver is, that it can accept
// more parent IDs.. not only one "100" as in our example
// so if we neet children of 100,101,102
// we can get more from this syntax: new List<int> {100, 101,102...};
departments = session
.QueryOver<Department>()
.Where(Restrictions.On<Department>(x=> x.Parent.Id)
.IsIn(parents))
.List();
// this style is just a bit more straightforward
// saving few chars of code, using 'WhereRestrictionOn'
departments = session
.QueryOver<Department>()
.WhereRestrictionOn(x => x.Parent.Id).IsIn(parents)
.List();
// in case we do have the only one parent ID to search for
// we do not have to use the IS IN
departments = session
.QueryOver<Department>()
.Where(x => x.Parent.Id == 100)
.List();
더보기 : 16.2. Simple Expressions