javid wrote:
The class Data does not belong to any table. It is just a Data class that I would like to use in my application.
Can I achieve this functionality using NHibernate? If so, can someone give me an example mapping file?
Thanks,
Javid
Are the Names, Locations and Brands stored in the database? Are they being handled by NHibernate?
If so, then in sounds like you just want to have a lookup list that you hold on to and can use whenver you need it. Is that right?
From my experience, this sounds like a bad idea. I'm no expert on sessions, but it seems like you could get into session issues by loading those lists early and leaving them around. You would need to either leave the session open, or you would need to reconnect them? (Maybe someone can comment on the accuracy of this statement?)
Anyways, in my WinForms application, when I need to provide a list of choices, I populate an IList in the form itself. The form has its own session. When I'm done with the form, the IList goes away, too.
You can fill the IList with HQL. That is what I do. Here's a basic example of an HQL search;
Code:
IList<MyObjectClass> _list =
SearchByHQL(_session, "from MyBusinessObject as b where b.IsActive = 'Y'");
public static IList<T> SearchByHQL(ISession session, string hql)
{
IQuery q = session.CreateQuery(hql);
return q.List<T>();
}