Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHibernate Criteria: concatenating two columns with an IN Expression

This is the SQL that I want to accomplish:

WHERE domain_nm + '\' + group_nm in ('DOMAINNAME\USERNAME1','DOMAINNAME2\USERNAME2') 

I can't for the life of me find an appropriate Expression for this. And I don't think I can use two expressions as the domain name and the group name need to be concatenated.

Thanks!

like image 820
Ahoapap Avatar asked Sep 13 '25 13:09

Ahoapap


1 Answers

Can you not use two Expressions?

criteria
  .Add(Expression.In("DomainName", new string[] { "DOMAINNAME", "DOMAINNAME2" }))
  .Add(Expression.In("GroupName", new string[] { "USERNAME1", "USERNAME2" })

The other option is to use Expression.Sql.

like image 185
kͩeͣmͮpͥ ͩ Avatar answered Sep 16 '25 12:09

kͩeͣmͮpͥ ͩ