/// <summary>
        /// 创建一个包装好的OrderBySqlClauseBuilder
        /// </summary>
        /// <param name="sourceBuilder"></param>
        /// <returns></returns>
        public static OrderBySqlClauseBuilder CreateWrapperBuilder(IEnumerable <IOrderByRequestItem> sourceBuilder)
        {
            OrderBySqlClauseBuilder result = sourceBuilder as OrderBySqlClauseBuilder;

            if (result == null)
            {
                result = new OrderBySqlClauseBuilder();

                foreach (IOrderByRequestItem sourceItem in sourceBuilder)
                {
                    result.Add(new SqlClauseBuilderItemOrd(sourceItem));
                }
            }

            return(result);
        }
예제 #2
0
        /// <summary>
        /// 根据条件和排序得到查询语句
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="orderByBuilder"></param>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public string GetLoadSqlByBuilder(string condition, OrderBySqlClauseBuilder orderByBuilder, string tableName)
        {
            string sql = string.Format("SELECT * FROM {0}", tableName);

            if (condition.IsNotEmpty())
            {
                sql = sql + string.Format(" WHERE {0}", condition);
            }

            if (orderByBuilder != null)
            {
                sql = sql + string.Format(" ORDER BY {0}", orderByBuilder.ToSqlString(TSqlBuilder.Instance));
            }

            return(sql);
        }
예제 #3
0
        /// <summary>
        /// 构造查询语句
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="orderByBuilder"></param>
        /// <param name="tableName"></param>
        /// <param name="timePoint"></param>
        /// <returns></returns>
        public string GetLoadSqlByBuilder(string condition, OrderBySqlClauseBuilder orderByBuilder, DateTime timePoint, string tableName)
        {
            string sql = string.Format("SELECT * FROM {0} WHERE ", tableName);

            ConnectiveSqlClauseCollection timePointBuilder = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint);

            if (condition.IsNotEmpty())
            {
                sql = sql + condition;
            }

            sql += " AND " + timePointBuilder.ToSqlString(TSqlBuilder.Instance);

            if (orderByBuilder != null)
            {
                sql = sql + string.Format(" ORDER BY {0}", orderByBuilder.ToSqlString(TSqlBuilder.Instance));
            }

            return(sql);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sqlContext"></param>
        /// <param name="condition"></param>
        /// <param name="orderByBuilder"></param>
        /// <param name="afterLoadAction"></param>
        /// <param name="action"></param>
        /// <param name="createNewAction"></param>
        /// <param name="timePoint"></param>
        /// <param name="tableName"></param>
        /// <param name="mappings"></param>
        public void RegisterLoadByBuilderInContext(SqlContextItem sqlContext, string condition, OrderBySqlClauseBuilder orderByBuilder, Action <TCollection> afterLoadAction, Action <TCollection> action, Func <DataRow, T> createNewAction, DateTime timePoint, string tableName, ORMappingItemCollection mappings)
        {
            if (mappings == null)
            {
                mappings = this.GetQueryMappingInfo();
            }

            if (tableName.IsNullOrEmpty())
            {
                tableName = GetQueryTableName(mappings, timePoint);
            }

            string sql = GetLoadSqlByBuilder(condition, orderByBuilder, timePoint, tableName);

            this.RegisterQueryData(sqlContext, tableName, mappings, sql, (collection) =>
            {
                if (afterLoadAction != null)
                {
                    afterLoadAction(collection);
                }

                if (action != null)
                {
                    action(collection);
                }
            },
                                   createNewAction);
        }