That's not how you create a criteria query.
The name of the property is LoadType, not LoadTypeId (which I guess is the
value of your LoadTypeId constant/property/something. It would help if you
showed us)

Also, all NH query methods (except SQL, that is) work on properties, classes
and object relations, not columns, tables and foreign keys.

   Diego


On Mon, Apr 5, 2010 at 21:00, Ashwin <[email protected]> wrote:

> Hello Guys,
>
> I have a class called Load which maps to a Load table and this table
> has foreign keys to Load_Type table and Truck_Type table.
>
> Now I can query the load table with all the columns using criteria API
> but when I try to query using the foreign key it gives me an error
> saying could not resolve property,
>
> Here is the method
>
>   public IList<Load> GetLoadsByLoadType(int loadType)
>        {
>            return _session.CreateCriteria(typeof(Load))
>               .Add(Expression.Eq(Load.MappingNames.LoadTypeId,
> loadType))
>               .List<Load>();
>        }
>
> Here is the mapping in the Load.hbm.xml
>
>  <many-to-one name="LoadType" cascade="save-update"
> column="`LoadtypeId`"/>
>
> I donno why I get these errors only when I try to query using the
> Foreign key.
>
> Hoping for some help.
>
> Ash
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to