Monthly Archives: January 2023

NHibernate ‘IN’ clause with linq

NHibernate was giving me fits, not letting me use ‘.In’ in the linq statements.

Here is how I got it to go:

 IQueryable<int?> idsForOrgList = _repo.Get<OrganizationThingyXref>().Where(thingy => thingy.OrganizationID == orgId && thingy.IdICareAbout != null).Select(_=>_.IdICareAbout);
           
List<People> ThingysInOrg = _repo.Get<Thingy>().Where(_ => idsForOrgList.Contains(_.IdICareAbout)).ToList();