Sample query to use with XXXFactory.LoadXXXByQuery(...,...)

I am trying to load an object using the generated LoadXXXByQuery. But I could not get it to understand my query string.

Example,

 
Car car = CarFactory.LoadCarByQuery("where car.Owner.ORMID = '1'", null)
 

Basically I am trying to get a car owned by a specific Owner. But NHibernate keeps throwing exception like so…

 
could not resolve property:Owner of :Lesen.Car [From Lesen.Car as Car Where Car.Owner.ORMID = '1']
 

Lesen is the package name for my classes.

Any code sample that explains how to use this function would be good.

Hello rosdikasim,

Try this:

Car car = CarFactory.LoadCarByQuery(“Car.owner.id = 1”, null);

PS. Notice that the statement is case sensitive. We assume that Car starts with capital letter ‘C’, and owner starts with small letter ‘o’.

Best regards,
Jick

Duh!.. I didnt realize that I am supposed to refer to the “name” property in the mapping file and not the class name!

So the correct query is “Car.ORM_Owner.Id = 1”

Everything work fine now. TQ.

You are welcome! :-o