Esempio n. 1
0
 /// <summary>
 ///   增加排序字段集合
 /// </summary>
 /// <param name = "oc">排序字段集合</param>
 public override sealed void AddRange(OrderCollections oc)
 {
     lock (syncRoot)
     {
         innerNoC.AddRange(oc);
     }
 }
Esempio n. 2
0
 /// <summary>
 ///   从集合增加排序字段
 /// </summary>
 /// <param name = "oc">集合</param>
 public virtual void AddRange(OrderCollections oc)
 {
     if (oc != null)
     {
         foreach (var text in oc.FieldNames)
         {
             Add(text, oc[text]);
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 解析Sql
        /// </summary>
        /// <param name = "tableName">物理表名称</param>
        /// <param name = "queryGroup">查询组</param>
        /// <param name = "orderBy">排序组</param>
        /// <returns>返回解析后的sql</returns>
        public static string __ParseSelectSQL(string tableName, QueryGroupConditionCollections queryGroup,
                                              OrderCollections orderBy, ConnectionModes cnnmode)
        {
            var sqlBuilder = new StringBuilder();
            if (string.IsNullOrEmpty(tableName))
                throw new Exception("无效的表名称!");

            sqlBuilder.AppendFormat("select * from {0} ", tableName);
            if (queryGroup != null && queryGroup.Count > 0)
            {
                var queryCount = queryGroup.Sum(qry => qry.FieldConditions.Count);
                if (queryCount > 0)
                {
                    sqlBuilder.AppendFormat(" where ");
                    for (var i = 0; i < queryGroup.Count; i++)
                    {
                        var qry = queryGroup[i];
                        sqlBuilder.AppendFormat(" (");
                        for (var j = 0; j < qry.FieldConditions.Count; j++)
                        {
                            var field = qry.FieldConditions[j];

                            //支持sql 拼接
                            if (field.Operator == OperatorType.SqlText)
                                sqlBuilder.AppendFormat(" {0} ", field.Value);
                            else
                                sqlBuilder.AppendFormat(" {0} {1} {2} ", field.FieldName,
                                                        GetOperatorType(field.Operator),
                                                        FormatSQLValue(field.Value, cnnmode));
                            if (j < qry.FieldConditions.Count - 1)
                                sqlBuilder.AppendFormat(" {0} ", GetWhereUnionType(field.NextUnionType));
                        }
                        sqlBuilder.AppendFormat(") ");
                        if (i < (queryGroup.Count - 1))
                            sqlBuilder.AppendFormat(" {0} ", GetWhereUnionType(qry.NextUnionType));
                    }
                }
            }
            if (orderBy != null && orderBy.Count > 0)
            {
                sqlBuilder.Append(" order by ");
                for (var n = 0; n < orderBy.FieldNames.Length; n++)
                {
                    var fieldName = orderBy.FieldNames[n];
                    sqlBuilder.AppendFormat(" {0} {1} ", fieldName, GetOrderByType(orderBy[fieldName]));
                    if (n < (orderBy.FieldNames.Length - 1))
                        sqlBuilder.Append(",");
                }
            }
            Console.WriteLine("create sql:" + sqlBuilder);
            return sqlBuilder.ToString();
        }
Esempio n. 4
0
 ///<summary>
 ///  获取表数据
 ///</summary>
 ///<param name = "tableName">表名称</param>
 ///<param name = "query">单组查询</param>
 ///<param name = "orderBy">排序</param>
 ///<returns>DataTable</returns>
 public DataTable SelectFromTable(string tableName, QueryGroupCondition query, OrderCollections orderBy)
 {
     return SelectFromTable(tableName, query, orderBy, null);
 }
Esempio n. 5
0
 /// <summary>
 /// 获取表数据
 /// </summary>
 /// <param name="tableName">表名称</param>
 /// <param name="query">单组查询</param>
 /// <param name="orderBy">排序</param>
 /// <param name="pagination">分页结构</param>
 /// <returns>
 /// DataTable
 /// </returns>
 public DataTable SelectFromTable(string tableName, QueryGroupCondition query, OrderCollections orderBy,
                                  Pagination pagination)
 {
     var queryGroup = new QueryGroupConditionCollections { query };
     return SelectFromTable(tableName, queryGroup, orderBy, pagination);
 }
Esempio n. 6
0
        /// <summary>
        /// 获取表数据
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="queryGroup">查询组</param>
        /// <param name="orderBy">排序</param>
        /// <param name="pagination">分页结构</param>
        /// <returns>
        /// DataTable
        /// </returns>
        /// <exception cref="Exception">所有错误信息</exception>
        public DataTable SelectFromTable(string tableName, QueryGroupConditionCollections queryGroup,
                                         OrderCollections orderBy, Pagination pagination)
        {
            var sql = __ParseSelectSQL(tableName, queryGroup, orderBy, this._ConnectionMode);

            return SelectFromTable(tableName, sql, pagination);
        }
Esempio n. 7
0
 /// <summary>
 ///   增加排序字段集合
 /// </summary>
 /// <param name = "oc">排序字段集合</param>
 public override sealed void AddRange(OrderCollections oc)
 {
     lock (syncRoot)
     {
         innerNoC.AddRange(oc);
     }
 }
Esempio n. 8
0
 /// <summary>
 ///   构造
 /// </summary>
 /// <param name = "noc">排序集合</param>
 public SynOrderCollections(OrderCollections noc)
 {
     innerNoC = noc;
 }
Esempio n. 9
0
 /// <summary>
 ///   从集合增加排序字段
 /// </summary>
 /// <param name = "oc">集合</param>
 public virtual void AddRange(OrderCollections oc)
 {
     if (oc != null)
     {
         foreach (var text in oc.FieldNames)
         {
             Add(text, oc[text]);
         }
     }
 }
Esempio n. 10
0
 /// <summary>
 ///   构造
 /// </summary>
 /// <param name = "noc">排序集合</param>
 public SynOrderCollections(OrderCollections noc)
 {
     innerNoC = noc;
 }