Nhibernate Linq查询QueryOver

时间:2011-08-09 13:46:23

标签: nhibernate linq-to-nhibernate queryover

我有以下代码:

1: ids = GetAnArrayOfIds();

2: jobEntities = jobEntities.Where(j => j.Locations.Select(l => l.Id).Any(ids.Contains));

如何使用QueryOver编写2?

谢谢,

1 个答案:

答案 0 :(得分:5)

var results = session.QueryOver<Job>()
    .JoinQueryOver<Location>(u => u.Locations)
    .Where(loc => loc.Id.IsIn(ids))
    .TransformUsing(Transformers.DistinctRootEntity)
    .List();

希望这有帮助