Diego, You are the best :) .. Thanks a ton.
Ashwin On Apr 5, 8:12 pm, Diego Mijelshon <[email protected]> wrote: > The first line was a little harsh, sorry about that (I meant to delete it > and I had already hit Send). > What I meant to say is that you ned to model your queries after your object > model and not your relational implementation. > The existence of that "MappingNames" helper tells me you don't like strings. > If that's the case, you should look into QueryOver (new in NH 3) and Linq > (also exists in 2.x, with a different implementation) > > Diego > > On Mon, Apr 5, 2010 at 21:08, Diego Mijelshon <[email protected]>wrote: > > > > > 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.
