Exemple #1
0
        public void SetBestRowIdentifiers()
        {
            int[] source = null;
            int   count  = 0;
            bool  flag   = false;
            int   num2   = 0;

            if (this.ColNotNull != null)
            {
                this.BestIndex          = null;
                this.BestIndexForColumn = new int[this.ColTypes.Length];
                ArrayUtil.FillArray(this.BestIndexForColumn, -1);
                for (int i = 0; i < this.IndexList.Length; i++)
                {
                    Index index          = this.IndexList[i];
                    int[] columns        = index.GetColumns();
                    int   visibleColumns = index.GetVisibleColumns();
                    if (visibleColumns != 0)
                    {
                        if (i == 0)
                        {
                            flag = true;
                        }
                        if (this.BestIndexForColumn[columns[0]] == -1)
                        {
                            this.BestIndexForColumn[columns[0]] = i;
                        }
                        else
                        {
                            Index index2 = this.IndexList[this.BestIndexForColumn[columns[0]]];
                            if (visibleColumns > index2.GetColumns().Length)
                            {
                                this.BestIndexForColumn[columns[0]] = i;
                            }
                        }
                        if (!index.IsUnique())
                        {
                            if (this.BestIndex == null)
                            {
                                this.BestIndex = index;
                            }
                        }
                        else
                        {
                            int num5 = 0;
                            for (int j = 0; j < visibleColumns; j++)
                            {
                                if (this.ColNotNull[columns[j]])
                                {
                                    num5++;
                                }
                            }
                            if (this.BestIndex != null)
                            {
                                this.BestIndex = index;
                            }
                            if (num5 == visibleColumns)
                            {
                                if (((source == null) || (count != num2)) || (visibleColumns < count))
                                {
                                    source = columns;
                                    count  = visibleColumns;
                                    num2   = visibleColumns;
                                    flag   = true;
                                }
                            }
                            else if (!flag && (((source == null) || (visibleColumns < count)) || (num5 > num2)))
                            {
                                source = columns;
                                count  = visibleColumns;
                                num2   = num5;
                            }
                        }
                    }
                }
                if ((source == null) || (count == source.Length))
                {
                    this.BestRowIdentifierCols = source;
                }
                else
                {
                    this.BestRowIdentifierCols = ArrayUtil.ArraySlice(source, 0, count);
                }
                this.BestRowIdentifierStrict = flag;
                if (this.IndexList[0].GetColumnCount() > 0)
                {
                    this.BestIndex = this.IndexList[0];
                }
            }
        }