Cannot use collections with InExpression

后端 未结 1 1075
闹比i
闹比i 2021-01-21 03:20

I\'ve just delved into a bit of NHibernate and I\'m having trouble with one of the more \'complex\' (to me!) queries I have to write. The scenario is:

I\'ve got a \'Staf

1条回答
  •  别那么骄傲
    2021-01-21 04:09

    You need to

    .CreateAlias("Skills", "sks")
    .Add(Restrictions.In("sks.id", skillIdList))
    

    I'm not sure if this can be done with a list of skill objects. Either way, the sql is going to end up the same as above.

    Note that this will create a Cartesian product so you might want to use an exists subquery or .SetResultTransformer(new DistinctRootEntityResultTransformer()) to get back a list of distinct Staff.

    0 讨论(0)
提交回复
热议问题