After examining some my problem outlined in this
post, I realized it was my IQuery that was causing problems. I'm hoping what I'm attempting is possible.
What I have is a
Project business object that contains a bag of "Mode" enumeration types. This is essentially a many-to-many relationship to a look-up table, except I'm eliminating the look-up table in favor of an enumeration.
I want to be able to perform the following IQuery:
Code:
IQuery query =
NHibernateSession.CreateQuery(
"FROM Project as pj WHERE pj.Modes IN (:ProjectModes) ");
ArrayList projects = new ArrayList();
projects.Add(ProjectMode.Mail);
projects.Add(ProjectMode.Phone);
query.SetParameterList("ProjectModes", projects);
In essence, "All the projects that have modes in a provided list of project modes".
Am I even approaching this the right way?
Is this even possible?
Would I be better served to just create a modes business object an map it to a table?
The Enum:
Code:
public enum ProjectMode
{
Web = 0,
Mail,
DataEntry,
Phone,
Consulting,
DataAnalysis,
FocusGroup,
CognitiveIntrviews,
Other = 100,
}
Snippet from the Project.hbm file:
Code:
<bag name="Modes" access="property" lazy="false" cascade="none" table="ut_ProjModes">
<key column="prKey"/>
<element column="prMode" type="SESRC.Scheduler.Core.Domain.ProjectMode, SESRC.Scheduler.Core" />
</bag>
DDL for the mapping table:
Code:
CREATE TABLE [dbo].[ut_ProjModes](
[prKey] [int] NOT NULL,
[prMode] [smallint] NOT NULL
)
prKey - Project table
prMode - Mode "table", which I'm trying to replace with an enumeration.
Thanks
Jack