示例#1
0
        /// <summary>
        /// 根据指定条件删除职位
        /// </summary>
        /// <param name="positionSearcher">职位查询对象</param>
        /// <param name="tran">中间事务对象</param>
        public void Delete(PositionSearcher positionSearcher, ICTransaction tran)
        {
            PositionSearcher     querySearcher = null;
            HibernateTransaction hTran         = null;
            ISession             session       = null;
            HQLQueryParser       queryParser   = new HQLQueryParser();
            StringBuilder        query         = new StringBuilder();

            query.Append("DELETE FROM ");
            query.Append("  Position  ");
            query.Append("WHERE ");
            query.Append("  PositionId IN (");
            query.Append("    SELECT ");
            query.Append("      P.PositionId ");
            query.Append("    FROM ");
            query.Append("      Position P ");

            if (positionSearcher != null)
            {
                querySearcher           = (PositionSearcher)positionSearcher.Clone();
                querySearcher.TableName = "P";

                if (querySearcher.CurrCompany != null)
                {
                    querySearcher.CurrCompany.TableName = "C";
                    query.Append("LEFT JOIN ");
                    query.Append("  P.CurrCompany C ");
                }

                if (querySearcher.CurrDepartment != null)
                {
                    querySearcher.CurrDepartment.TableName = "D";
                    query.Append("LEFT JOIN ");
                    query.Append("  P.CurrDepartment D ");
                }
            }

            queryParser.SearcherParse(querySearcher);

            if (!string.IsNullOrEmpty(queryParser.ConditionString))
            {
                query.Append("WHERE ");
                query.Append("  " + queryParser.ConditionString);
            }

            query.Append(")");

            if (tran != null)
            {
                hTran   = (HibernateTransaction)tran;
                session = hTran.CurrentSession;
            }
            else
            {
                session = this.CurrentHibernateConfig.GetCurrentSession();
            }

            int effectCount = HibernateHelper.DeleteObjectByHQL(session, query.ToString(), queryParser.ParamCollection);
        }
示例#2
0
        /// <summary>
        /// 根据指定条件删除公司
        /// </summary>
        /// <param name="companySearcher">公司查询对象</param>
        /// <param name="tran">中间事务对象</param>
        public void Delete(CompanySearcher companySearcher, ICTransaction tran)
        {
            CompanySearcher      querySearcher = null;
            HibernateTransaction hTran         = null;
            ISession             session       = null;
            HQLQueryParser       queryParser   = new HQLQueryParser();
            StringBuilder        query         = new StringBuilder();

            query.AppendLine("DELETE FROM ");
            query.AppendLine("   Company C ");

            if (companySearcher != null)
            {
                querySearcher           = (CompanySearcher)companySearcher.Clone();
                querySearcher.TableName = "C";
            }

            queryParser.SearcherParse(querySearcher);

            if (!string.IsNullOrEmpty(queryParser.ConditionString))
            {
                query.AppendLine("WHERE ");
                query.AppendLine("   " + queryParser.ConditionString);
            }

            if (tran != null)
            {
                hTran   = (HibernateTransaction)tran;
                session = hTran.CurrentSession;
            }
            else
            {
                session = this.CurrentHibernateConfig.GetCurrentSession();
            }

            int effectCount = HibernateHelper.DeleteObjectByHQL(session, query.ToString(), queryParser.ParamCollection);
        }