I have never used NHibernate, but the problem is that the Username definition is in the model and not in the database.
You basically have two options (remember that I have never used NHibernate, but other entities / ORMs) and maybe the third one depending on the implementation of IQueryable in NHibernate.
Load the entire table into memory (if it is small, and you often execute this query, which may be useful because I assume NHibernate has some smart caching?):
User user = _session.QueryOver<User>().ToList().FirstOrDefault(x => x.Username == "Hamza");
The second checks the encrypted string provided by @Diode:
// Resolve string, since we are using LINQ2SQSL in some form var encName = _encryptionProvider.Encrypt("Hamza"); User user = _session.QueryOver<User>().FirstOrDefault(x => x.SecuredUsername == encName);
If you can use a specific instance of IQueryable for packaging purposes, this will be one solution. See http://msdn.microsoft.com/en-us/library/bb351562.aspx for a description of IQueryable.
But basically, encryption should occur on the server, that is, not in the database, and this limits your options.
EDIT: Searching for all users matching "Hamz *" we need to load into memory and check there:
var users = _session.QueryOver<User>().ToList().Where(x => x.Username.StartsWith("Hamz"));
source share