コード例 #1
0
 public TimeSeriesIndex()
 {
     MACDIndex  = new MACDIndex();
     RSIIndex   = new RSIIndex();
     GuppyIndex = new GuppyIndex();
     SOIndex    = new SOIndex();
 }
コード例 #2
0
        /// <summary>
        /// 获取表所拥有的索引列表
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public virtual List <SOIndex> GetTableIndexList(SOTable table)
        {
            List <SOIndex> list = new List <SOIndex>();

            string[] restrictions = new string[4];
            restrictions[0] = table.Database.Name;
            //restrictions[4] = table.Name;
            DataTable dt = GetSchema(MetaDataCollectionName_Indexes, restrictions);

            foreach (DataRow dr in dt.Rows)
            {
                if (dr["TABLE_NAME"].ToString() != table.Name)
                {
                    continue;
                }

                SOIndex index = new SOIndex();
                index.Name            = dr["INDEX_NAME"].ToString();
                index.IndexColumnName = dr["COLUMN_NAME"].ToString();
                index.IsPrimaryKey    = dr["PRIMARY_KEY"].ToString().ToLower() == "true" ? true : false;
                index.IsUnique        = dr["UNIQUE"].ToString().ToLower() == "true" ? true : false;
                index.IsCluster       = dr["CLUSTERED"].ToString().ToLower() == "true" ? true : false;
                index.IsIdentity      = dr["NULLS"].ToString() == "1" ? true : false; //这里判断自增列默认情况下是没问题的
                index.Comment         = index.Name;
                index.Parent          = table;

                list.Add(index);
            }

            return(list);
        }
コード例 #3
0
        /// <summary>
        /// 获取视图所拥有的索引列表
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        public override List <SOIndex> GetViewIndexList(SOView view)
        {
            string cmdText = string.Format(@"SELECT *  
                FROM INFORMATION_SCHEMA.`constraints` 
                WHERE table_schema='{0}' AND table_name='{1}';", view.Database.Name, view.Name);

            List <SOIndex>  indexList  = new List <SOIndex>();
            List <SOColumn> columnList = GetViewColumnList(view);
            DataTable       dt         = this.DbProvider.ExecuteDataSet(System.Data.CommandType.Text, cmdText).Tables[0];

            foreach (DataRow row in dt.Rows)
            {
                SOIndex index = new SOIndex
                {
                    Parent       = view,
                    Name         = row["constraint_name"].ToString(),
                    Comment      = row["constraint_name"].ToString(),
                    IsCluster    = false,
                    IsFullText   = row["constraint_type"].ToString() == "Full Text",
                    IsPrimaryKey = row["constraint_type"].ToString() == "PRIMARY KEY",
                    IsUnique     = row["constraint_type"].ToString() == "UNIQUE"
                };
                indexList.Add(index);

                string cmdText2 = string.Format(@"SELECT column_name  
                FROM INFORMATION_SCHEMA.`statistics` 
                WHERE table_schema='{0}' AND table_name='{1}';", view.Database.Name, view.Name);

                DataTable dt2 = this.DbProvider.ExecuteDataSet(CommandType.Text, cmdText2).Tables[0];
                index.Columns = new List <SOColumn>();
                foreach (DataRow row2 in dt2.Rows)
                {
                    foreach (SOColumn column in columnList)
                    {
                        if (row2[0].ToString() == column.Name)
                        {
                            index.Columns.Add(column);
                        }
                    }
                }
            }

            return(indexList);
        }