Register  |  Login




Advertisement

Start Your Own Q&A Site

Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.

Question

Status: Closed Points: 75 Time: 05:12 - Dec 08, 2006  

theDude

How do I use LIKE with a named parameter in the NHibernate query language?

I need to make a query like the following:

from Product WHERE field1 LIKE 'bla%'

but the "bla" is a parameter that I would like to add as a named parameter.
So it tried:
from Product WHERE field1 LIKE :field1 + '%'
But that doesn't give me any results.

Anyone knows how to do this?

Categories

Answer Discussion
Tutorials

 

Sergio Costa

Date:: Jan 05, 2007

Time:: 11:02

"select * from Product WHERE field1 LIKE @p1; @p1='blah%' "

theDude

Date:: Jan 06, 2007

Time:: 09:25

great, exactly what I was looking for.
I'll try it out and you'll get the points afterwards.

theDude

Date:: Jan 27, 2007

Time:: 07:31

hmmm, i have tried it now, but it doesn't work.
are you sure that your example is for the NHibernate query language? I'm not looking for an SQL way of doing it...

theDude

Date:: Jun 04, 2007

Time:: 01:46

didn't find the solution for this, but gotta close the question...

rajnarrayan500

Date:: Jan 16, 2009

Time:: 00:38

<query name="SEARCH_BLA">
<![CDATA[
Product WHERE field1 LIKE :field1]]>>

</query>

dONOT USE ANY % FOR HQL .
HOPE THIS WILL SOLVE.

robertstackhouse

Date:: May 18, 2010

Time:: 16:38

string queryString = "from Product product where product.field1 like :field1";

IQuery query = session.CreateQuery(queryString);
query.SetParameter("field1", "%" +field1+ "%");

IList<Product> products = query.List<Product>();

Question Answered

This question has been closed, and points have been rewarded to the following experts:


theDude: 75

You're welcome however to comment or give additional information or if you wish, you have the ability to write a Tutorial in the Tutorial Area.

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

No tutorials have been submitted yet. Want to be the first?

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

Ask a Question

Have a new question? Ask!

You have 100 characters to use



Top Experts

View More

Rank

Expert

Points

1.

nidhi

10354

2.

oracleofDelphi

6493

3.

rcastagna

5596

4.

LAGM

4848

5.

PeterNZ

3487

6.

gonzalo

2840

7.

Mason

2770

8.

jgivoni

2303

9.

xarcus

1820

10.

Anpanman

917

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it



Language Options

English:

www.quomon.com

Español:

www.quomon.es