string name = "John"; SqlString sql = new SqlString("SELECT * FROM Users WHERE Name LIKE ?"); sql.Add("%" + name, NHibernateUtil.String).StartsWithCaseInsensitive();
string domain = "@gmail.com"; SqlString sql = new SqlString("SELECT * FROM Users WHERE Email LIKE ?"); sql.Add("%" + domain, NHibernateUtil.String).StartsWithCaseInsensitive();In this example, NHibernate SqlString StartsWithCaseInsensitive is used to search for an email domain that starts with "@gmail.com." By adding the '%' symbol, it will search for any email that has "@gmail.com" anywhere in the string. NHibernate.SqlCommand.SqlString.StartsWithCaseInsensitive is part of NHibernate's core library and can be found in the NHibernate assembly.