AddEntity is essential

            /* too slowly
            IList<ResourceAssign> ra=NHibernateSessionManager.Instance.GetSession().CreateCriteria(typeof(ResourceAssign),"ra")
            .CreateAlias("TargetMemberResource","mr",JoinType.InnerJoin)
            .Add(Expression.Eq("mr.ID", memberResourceId))
            .CreateAlias("TargetFiscalYear","fy",JoinType.InnerJoin)
            .Add(Expression.Eq("fy.Id", fiscalYearId))
            .CreateAlias("TargetEffortEstimation","ee",JoinType.InnerJoin)
             .Add(Expression.Eq("ee.Id", effortestimationId)).List<ResourceAssign>();
            */
           
            StringBuilder sbSQL = new StringBuilder("SELECT *");
            sbSQL.Append(" FROM RESOURCE_ASSIGN ra");
            sbSQL.Append(" WHERE (ra.FK_FISCAL_YEAR_ID =:fyid) AND (ra.FK_EFFORT_ESTIMATION_ID =:eeid) AND (ra.FK_MEMBERRESOURCE_ID =:mrid)");

            IQuery sqlQuery = (IQuery)NHibernateSessionManager.Instance.GetSession().CreateSQLQuery(sbSQL.ToString()). AddEntity("ra",typeof(ResourceAssign))
             .SetInt64("fyid", fiscalYearId)
             .SetInt64("eeid", effortestimationId)
             .SetInt64("mrid", memberResourceId);
            IList<ResourceAssign> ra = sqlQuery.List<ResourceAssign>();
            return ra;

你可能感兴趣的:(entity)