2011-08-09 159 views
1

我有以下一段代碼:NHibernate的Linq查詢到QueryOver

1: ids = GetAnArrayOfIds(); 

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

如何使用QueryOver寫2?

謝謝

回答

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

希望這有助於

+0

它肯定不會,非常感謝 – Calin