當前位置: 首頁>>代碼示例>>C#>>正文


C# EmployeeSearcher.Clone方法代碼示例

本文整理匯總了C#中NFramework.DBTool.Test.Searcher.EmployeeSearcher.Clone方法的典型用法代碼示例。如果您正苦於以下問題:C# EmployeeSearcher.Clone方法的具體用法?C# EmployeeSearcher.Clone怎麽用?C# EmployeeSearcher.Clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NFramework.DBTool.Test.Searcher.EmployeeSearcher的用法示例。


在下文中一共展示了EmployeeSearcher.Clone方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FindDataTable

        /// <summary>
        /// 根據指定條件查找員工分頁集合
        /// </summary>
        /// <param name="employeeSearcher">員工查詢對象</param>
        /// <param name="pager">分頁對象</param>
        /// <param name="tran">中間事務對象</param>
        /// <returns>返回查找到的分頁集合,包括按條件可查詢到的所有記錄數和當前分頁的DataTable數據</returns>
        public PageDataTable FindDataTable(EmployeeSearcher employeeSearcher, Pager pager, ICTransaction tran)
        {
            EmployeeSearcher querySearcher = null;
            MysqlQueryParser queryParser = new MysqlQueryParser();
            PageDataTable pDataTable = new PageDataTable();
            DataSet resultSet = null;
            StringBuilder query = new StringBuilder();
            StringBuilder joinQuery = new StringBuilder();
            StringBuilder conditionQuery = new StringBuilder();
            StringBuilder sortQuery = new StringBuilder();

            if (employeeSearcher != null)
            {
                querySearcher = (EmployeeSearcher)employeeSearcher.Clone();
                querySearcher.TableName = "E";

                if (querySearcher.CurrCompany != null)
                {
                    querySearcher.CurrCompany.TableName = "C";
                    joinQuery.AppendLine(@"LEFT JOIN ");
                    joinQuery.AppendLine(@"   `Company` C ON(C.CompanyId = E.CompanyId) ");
                }

                if (querySearcher.CurrDepartment != null)
                {
                    querySearcher.CurrDepartment.TableName = "D";
                    joinQuery.AppendLine(@"LEFT JOIN ");
                    joinQuery.AppendLine(@"   `Department` D ON(D.DepartmentId = E.DepartmentId) ");
                }

                if (querySearcher.CurrPosition != null)
                {
                    querySearcher.CurrPosition.TableName = "P";
                    joinQuery.AppendLine(@"LEFT JOIN ");
                    joinQuery.AppendLine(@"   `Position` P ON(P.PositionId = E.PositionId) ");
                }
            }

            queryParser.SearcherParse(querySearcher);

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

            if (!string.IsNullOrEmpty(queryParser.SortString))
            {
                sortQuery.AppendLine(@"ORDER BY ");
                sortQuery.AppendLine(@"   " + queryParser.SortString);
            }

            query.AppendLine(@"SELECT ");
            query.AppendLine(@"   E.`EmployeeId` ");
            query.AppendLine(@"  ,E.`EmployeeCode` ");
            query.AppendLine(@"  ,E.`Name` ");
            query.AppendLine(@"  ,E.`Birthday` ");
            query.AppendLine(@"  ,E.`Sex` ");
            query.AppendLine(@"  ,E.`CompanyId` ");
            query.AppendLine(@"  ,E.`DepartmentId` ");
            query.AppendLine(@"  ,E.`PositionId` ");
            query.AppendLine(@"  ,E.`Rand` ");
            query.AppendLine(@"  ,E.`RVersion` ");
            query.AppendLine(@"  ,E.`Status` ");
            query.AppendLine(@"  ,E.`CreaterId` ");
            query.AppendLine(@"  ,E.`CreateTime` ");
            query.AppendLine(@"  ,E.`UpdatorId` ");
            query.AppendLine(@"  ,E.`UpdateTime` ");
            query.AppendLine(@"  ,E.`StartWorkDate` ");
            query.AppendLine(@"  ,E.`JoinDate` ");
            query.AppendLine(@"FROM ");
            query.AppendLine(@"  `Employee` E ");
            query.AppendLine(joinQuery.ToString());
            query.AppendLine(conditionQuery.ToString());
            query.AppendLine(sortQuery.ToString());

            if (pager != null && pager.PageSize != 0 && pager.StartRecord >= 0)
            {
                query.AppendLine(@" LIMIT " + pager.StartRecord.ToString() + "," + pager.PageSize + " ");
            }

            query.AppendLine(@"; ");

            if (tran != null)
            {
                resultSet = MySqlHelper.ExecuteDataset((MySqlConnection)tran.Connection, query.ToString(), queryParser.ParamCollection.ToArray());
            }
            else
            {
                resultSet = MySqlHelper.ExecuteDataset(this.CurrentConnectionString, query.ToString(), queryParser.ParamCollection.ToArray());
            }

            if (resultSet != null)
//.........這裏部分代碼省略.........
開發者ID:pmsun-bruce,項目名稱:DBTool,代碼行數:101,代碼來源:EmployeeDal.cs

示例2: Delete

        /// <summary>
        /// 根據指定條件刪除員工
        /// </summary>
        /// <param name="employeeSearcher">員工查詢對象</param>
        /// <param name="tran">中間事務對象</param>
        public void Delete(EmployeeSearcher employeeSearcher, ICTransaction tran)
        {
            int effectCount = 0;
            EmployeeSearcher querySearcher = null;
            MysqlQueryParser queryParser = new MysqlQueryParser();
            StringBuilder query = new StringBuilder();
            query.AppendLine(@"DELETE FROM ");
            query.AppendLine(@"   Employee ");
            query.AppendLine(@"WHERE ");
            query.AppendLine(@"   EmployeeId IN (");
            query.AppendLine(@"      SELECT ");
            query.AppendLine(@"         * ");
            query.AppendLine(@"      FROM ");
            query.AppendLine(@"         (SELECT ");
            query.AppendLine(@"             E.EmployeeId ");
            query.AppendLine(@"          FROM ");
            query.AppendLine(@"             Employee E ");

            if (employeeSearcher != null)
            {
                querySearcher = (EmployeeSearcher)employeeSearcher.Clone();
                querySearcher.TableName = "E";

                if (querySearcher.CurrCompany != null)
                {
                    querySearcher.CurrCompany.TableName = "C";
                    query.AppendLine(@"LEFT JOIN ");
                    query.AppendLine(@"   `Company` C ON(C.CompanyId = E.CompanyId) ");
                }

                if (querySearcher.CurrDepartment != null)
                {
                    querySearcher.CurrDepartment.TableName = "D";
                    query.AppendLine(@"LEFT JOIN ");
                    query.AppendLine(@"   `Department` D ON(D.DepartmentId = E.DepartmentId) ");
                }

                if (querySearcher.CurrPosition != null)
                {
                    querySearcher.CurrPosition.TableName = "P";
                    query.AppendLine(@"LEFT JOIN ");
                    query.AppendLine(@"   `Position` P ON(P.PositionId = E.PositionId) ");
                }
            }

            queryParser.SearcherParse(querySearcher);

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

            query.AppendLine(@") AS E1); ");

            try
            {
                if (tran != null)
                {
                    effectCount = MySqlHelper.ExecuteNonQuery((MySqlConnection)tran.Connection, query.ToString(), queryParser.ParamCollection.ToArray());
                }
                else
                {
                    effectCount = MySqlHelper.ExecuteNonQuery(this.CurrentConnectionString, query.ToString(), queryParser.ParamCollection.ToArray());
                }
            }
            catch(SqlException sex)
            {
                if (sex.ErrorCode == (int)ResultCode.FKError)
                {
                    throw new ResponseException((int)ResultCode.FKError, "DELETE Position");
                }
            }
        }
開發者ID:pmsun-bruce,項目名稱:DBTool,代碼行數:79,代碼來源:EmployeeDal.cs

示例3: Count

        /// <summary>
        /// 查詢員工數量
        /// </summary>
        /// <param name="employeeSearcher">員工查詢對象</param>
        /// <param name="tran">中間事務對象</param>
        /// <returns>返回查詢到的數量</returns>
        public long Count(EmployeeSearcher employeeSearcher, ICTransaction tran)
        {
            object count = 0;
            long result = 0;
            EmployeeSearcher querySearcher = null;
            MysqlQueryParser queryParser = new MysqlQueryParser();
            StringBuilder query = new StringBuilder();
            query.AppendLine(@"SELECT ");
            query.AppendLine(@"   COUNT(E.EmployeeId) ");
            query.AppendLine(@"FROM ");
            query.AppendLine(@"   Employee E ");

            if (employeeSearcher != null)
            {
                querySearcher = (EmployeeSearcher)employeeSearcher.Clone();
                querySearcher.TableName = "E";

                if (querySearcher.CurrCompany != null)
                {
                    querySearcher.CurrCompany.TableName = "C";
                    query.AppendLine(@"LEFT JOIN ");
                    query.AppendLine(@"   `Company` C ON(C.CompanyId = E.CompanyId) ");
                }

                if (querySearcher.CurrDepartment != null)
                {
                    querySearcher.CurrDepartment.TableName = "D";
                    query.AppendLine(@"LEFT JOIN ");
                    query.AppendLine(@"   `Department` D ON(D.DepartmentId = E.DepartmentId) ");
                }

                if (querySearcher.CurrPosition != null)
                {
                    querySearcher.CurrPosition.TableName = "P";
                    query.AppendLine(@"LEFT JOIN ");
                    query.AppendLine(@"   `Position` P ON(P.PositionId = E.PositionId) ");
                }
            }

            queryParser.SearcherParse(querySearcher);

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

            if (tran != null)
            {
                count = MySqlHelper.ExecuteScalar((MySqlConnection)tran.Connection, query.ToString(), queryParser.ParamCollection.ToArray());
            }
            else
            {
                count = MySqlHelper.ExecuteScalar(this.CurrentConnectionString, query.ToString(), queryParser.ParamCollection.ToArray());
            }

            return long.TryParse(count.ToString(), out result) ? result : 0;
        }
開發者ID:pmsun-bruce,項目名稱:DBTool,代碼行數:64,代碼來源:EmployeeDal.cs

示例4: FindDataTable

        /// <summary>
        /// 根據指定條件查找員工分頁集合
        /// </summary>
        /// <param name="employeeSearcher">員工查詢對象</param>
        /// <param name="pager">分頁對象</param>
        /// <param name="tran">中間事務對象</param>
        /// <returns>返回查找到的分頁集合,包括按條件可查詢到的所有記錄數和當前分頁的DataTable數據</returns>
        public PageDataTable FindDataTable(EmployeeSearcher employeeSearcher, Pager pager, ICTransaction tran)
        {
            EmployeeSearcher querySearcher = null;
            MssqlQueryParser queryParser = new MssqlQueryParser();
            PageDataTable pDataTable = new PageDataTable();
            DataSet resultSet = null;
            StringBuilder query = new StringBuilder();
            StringBuilder joinQuery = new StringBuilder();
            StringBuilder conditionQuery = new StringBuilder();
            StringBuilder sortQuery = new StringBuilder();

            if (employeeSearcher != null)
            {
                querySearcher = (EmployeeSearcher)employeeSearcher.Clone();
                querySearcher.TableName = "E";

                if (querySearcher.CurrCompany != null)
                {
                    querySearcher.CurrCompany.TableName = "C";
                    joinQuery.AppendLine(@"LEFT JOIN ");
                    joinQuery.AppendLine(@"   [Company] C ON(C.CompanyId = E.CompanyId) ");
                }

                if (querySearcher.CurrDepartment != null)
                {
                    querySearcher.CurrDepartment.TableName = "D";
                    joinQuery.AppendLine(@"LEFT JOIN ");
                    joinQuery.AppendLine(@"   [Department] D ON(D.DepartmentId = E.DepartmentId) ");
                }

                if (querySearcher.CurrPosition != null)
                {
                    querySearcher.CurrPosition.TableName = "P";
                    joinQuery.AppendLine(@"LEFT JOIN ");
                    joinQuery.AppendLine(@"   [Position] P ON(P.PositionId = E.PositionId) ");
                }
            }

            queryParser.SearcherParse(querySearcher);

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

            if (!string.IsNullOrEmpty(queryParser.SortString))
            {
                sortQuery.AppendLine(@"ORDER BY ");
                sortQuery.AppendLine(@"   " + queryParser.SortString);
            }

            query.AppendLine(@"SELECT ");
            query.AppendLine(@"   E.[EmployeeId] ");
            query.AppendLine(@"  ,E.[EmployeeCode] ");
            query.AppendLine(@"  ,E.[Name] ");
            query.AppendLine(@"  ,E.[Birthday] ");
            query.AppendLine(@"  ,E.[Sex] ");
            query.AppendLine(@"  ,E.[CompanyId] ");
            query.AppendLine(@"  ,E.[DepartmentId] ");
            query.AppendLine(@"  ,E.[PositionId] ");
            query.AppendLine(@"  ,E.[Rand] ");
            query.AppendLine(@"  ,E.[RVersion] ");
            query.AppendLine(@"  ,E.[Status] ");
            query.AppendLine(@"  ,E.[CreaterId] ");
            query.AppendLine(@"  ,E.[CreateTime] ");
            query.AppendLine(@"  ,E.[UpdatorId] ");
            query.AppendLine(@"  ,E.[UpdateTime] ");
            query.AppendLine(@"  ,E.[StartWorkDate] ");
            query.AppendLine(@"  ,E.[JoinDate] ");
            query.AppendLine(@"FROM ");
            query.AppendLine(@"  [Employee] E ");
            query.AppendLine(joinQuery.ToString());
            query.AppendLine(conditionQuery.ToString());
            query.AppendLine(sortQuery.ToString());
            query.AppendLine(@"; ");

            if (tran != null)
            {
                DbTransaction dbTran = ((MssqlTransaction)tran).CurrentTransaction;

                if (pager != null)
                {
                    resultSet = MssqlHelper.ExecuteDataSet(dbTran, CommandType.Text, query.ToString(), pager, "Employee", queryParser.ParamCollection);
                }
                else
                {
                    resultSet = MssqlHelper.ExecuteDataSet(dbTran, CommandType.Text, query.ToString(), queryParser.ParamCollection);
                }
            }
            else
            {
                if (pager != null)
//.........這裏部分代碼省略.........
開發者ID:pmsun-bruce,項目名稱:DBTool,代碼行數:101,代碼來源:EmployeeDal.cs

示例5: FindList

        /// <summary>
        /// 查找指定條件的員工分頁集合
        /// </summary>
        /// <param name="employeeSearcher">員工查詢對象</param>
        /// <param name="pager">分頁對象</param>
        /// <param name="tran">中間事務對象</param>
        /// <returns>返回查找到的分頁集合,包括按條件可查詢到的所有記錄數和當前分頁的對象集合</returns>
        public PageList<Employee> FindList(EmployeeSearcher employeeSearcher, Pager pager, ICTransaction tran)
        {
            EmployeeSearcher querySearcher = null;
            HibernateTransaction hTran = null;
            ISession session = null;
            PageList<Employee> pList = new PageList<Employee>();
            HQLQueryParser queryParser = new HQLQueryParser();
            StringBuilder query = new StringBuilder();

            query.Append("SELECT ");
            query.Append(" E ");
            query.Append("FROM ");
            query.Append("  Employee E ");

            if (employeeSearcher != null)
            {
                querySearcher = (EmployeeSearcher)employeeSearcher.Clone();
                querySearcher.TableName = "E";

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

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

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

            queryParser.SearcherParse(querySearcher);

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

            if (!string.IsNullOrEmpty(queryParser.SortString))
            {
                query.Append("ORDER BY ");
                query.Append("  " + queryParser.SortString);
            }

            if (tran != null)
            {
                hTran = (HibernateTransaction)tran;
                session = hTran.CurrentSession;
                pList.TotalCount = this.Count(querySearcher, tran);
            }
            else
            {
                session = this.CurrentHibernateConfig.GetCurrentSession();
                pList.TotalCount = this.Count(querySearcher);
            }

            if (pager != null)
            {
                pList.RecordList = HibernateHelper.FindObjectListByHQL<Employee>(session, query.ToString(), queryParser.ParamCollection, pager);
            }
            else
            {
                pList.RecordList = HibernateHelper.FindObjectListByHQL<Employee>(session, query.ToString(), queryParser.ParamCollection);
            }

            return pList;
        }
開發者ID:pmsun-bruce,項目名稱:DBTool,代碼行數:85,代碼來源:EmployeeDal.cs

示例6: Delete

        /// <summary>
        /// 根據指定條件刪除員工
        /// </summary>
        /// <param name="employeeSearcher">員工查詢對象</param>
        /// <param name="tran">中間事務對象</param>
        public void Delete(EmployeeSearcher employeeSearcher, ICTransaction tran)
        {
            EmployeeSearcher querySearcher = null;
            HibernateTransaction hTran = null;
            ISession session = null;
            HQLQueryParser queryParser = new HQLQueryParser();
            StringBuilder query = new StringBuilder();

            query.Append("DELETE FROM ");
            query.Append("  Employee  ");
            query.Append("WHERE ");
            query.Append("  EmployeeId IN (");
            query.Append("    SELECT ");
            query.Append("      E.EmployeeId ");
            query.Append("    FROM ");
            query.Append("      Employee E ");

            if (employeeSearcher != null)
            {
                querySearcher = (EmployeeSearcher)employeeSearcher.Clone();
                querySearcher.TableName = "E";

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

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

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

            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);
        }
開發者ID:pmsun-bruce,項目名稱:DBTool,代碼行數:71,代碼來源:EmployeeDal.cs


注:本文中的NFramework.DBTool.Test.Searcher.EmployeeSearcher.Clone方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。