views:

55

answers:

1

I need to give to a Criteria a list of string receive another one, the sql that makes this is:

select loginName from SimpleUsers 
where loginName in ('admin', 'oscar', 'stig')

but I need it in NHinbernate criteria, can anyone please help me with this ?

+7  A: 

You may try this:

var loginNames = session
    .CreateCriteria<SimpleUsers>()
    .Add(Restrictions.In("loginName", new[] { "admin", "oscar", "stig" }))
    .SetProjection(Projections.Property("loginName"))
    .List<string>();
Darin Dimitrov