7
Ho implementato una funzione di ricerca utilizzando Castel Active Record. Ho pensato che il codice è abbastanza semplice, ma ho continuato a ottenerenibernare hql con parametro denominato
NHibernate.QueryParameterException: non riusciva a individuare il nome dei parametri [searchKeyWords]
errori. Qualcuno può dirmi cosa è andato storto? Grazie mille.
public List<Seller> GetSellersWithEmail(string searchKeyWords)
{
if (string.IsNullOrEmpty(searchKeyWords))
{
return new List<Seller>();
}
string hql = @"select distinct s
from Seller s
where s.Deleted = false
and (s.Email like '%:searchKeyWords%')";
SimpleQuery<Seller> q = new SimpleQuery<Seller>(hql);
q.SetParameter("searchKeyWords", searchKeyWords);
return q.Execute().ToList();
}
Non ho ancora confermato la soluzione, ma ho avuto una risposta simile da http://www.stpe.se/2008/07/hibernate-hql-like-query-named-parameters/ e quella soluzione ha funzionato. Quindi, assumerò che anche il tuo sia giusto. Grazie mille. –