GetRecordFromVersion() приватный Метод

private GetRecordFromVersion ( DataRowVersion version ) : int
version DataRowVersion
Результат int
Пример #1
0
        internal override object Eval(DataRow row, DataRowVersion version)
        {
            if (!found)
            {
#if DEBUG
                if (CompModSwitches.NameNode.TraceVerbose)
                {
                    Debug.WriteLine("Can not find column " + name);
                }
#endif
                throw ExprException.UnboundName(name);
            }

            if (row == null)
            {
                if (IsTableConstant()) // this column is TableConstant Aggregate Function
                {
                    return(column.DataExpression.Evaluate());
                }
                else
                {
#if DEBUG
                    if (CompModSwitches.NameNode.TraceVerbose)
                    {
                        Debug.WriteLine("Can not eval column without a row.." + name);
                    }
#endif
                    throw ExprException.UnboundName(name);
                }
            }

            return(column[row.GetRecordFromVersion(version)]);
        }
Пример #2
0
 internal override object Eval(DataRow row, DataRowVersion version)
 {
     if (!this.found)
     {
         throw ExprException.UnboundName(this.name);
     }
     if (row != null)
     {
         return(this.column[row.GetRecordFromVersion(version)]);
     }
     if (!this.IsTableConstant())
     {
         throw ExprException.UnboundName(this.name);
     }
     return(this.column.DataExpression.Evaluate());
 }
Пример #3
0
        internal override object Eval(DataRow row, DataRowVersion version)
        {
            if (!found)
            {
                throw ExprException.UnboundName(name);
            }

            if (row == null)
            {
                if (IsTableConstant()) // this column is TableConstant Aggregate Function
                {
                    return(column.DataExpression.Evaluate());
                }
                else
                {
                    throw ExprException.UnboundName(name);
                }
            }

            return(column[row.GetRecordFromVersion(version)]);
        }
Пример #4
0
        internal override object Eval(DataRow row, DataRowVersion version) {
            if (!found) {
                throw ExprException.UnboundName(name);
            }

            if (row == null) {
                if(IsTableConstant()) // this column is TableConstant Aggregate Function
                    return column.DataExpression.Evaluate();
                else {
                    throw ExprException.UnboundName(name);
                }
            }

            return column[row.GetRecordFromVersion(version)];
        }
Пример #5
0
        internal void SilentlySetValue(DataRow dr, DataColumn dc, DataRowVersion version, object newValue) {
            // get record for version
            int record = dr.GetRecordFromVersion(version);

            bool equalValues = false;
            if (DataStorage.IsTypeCustomType(dc.DataType) && newValue != dc[record]) {
                // if UDT storage, need to check if reference changed. See bug 385182
                equalValues = false;
            }
            else {
                equalValues = dc.CompareValueTo(record, newValue, true);
            }

            // if expression has changed
            if (!equalValues) {
                int[] oldIndex = dr.Table.RemoveRecordFromIndexes(dr, version);// conditional, if it exists it will try to remove with no event fired
                dc.SetValue(record, newValue);
                int[] newIndex = dr.Table.InsertRecordToIndexes(dr, version);// conditional, it will insert if it qualifies, no event will be fired
                if (dr.HasVersion(version)) {
                    if (version != DataRowVersion.Original) {
                        dr.Table.RecordChanged(oldIndex, newIndex);
                    }
                    if (dc.dependentColumns != null) {
                        //BugBug - passing in null for cachedRows.  This means expression columns as keys does not work when key changes.
                        dc.Table.EvaluateDependentExpressions(dc.dependentColumns, dr, version, null);
                    }
                }
             }
             dr.ResetLastChangedColumn();
        }
Пример #6
0
// InsertRecordToIndexes inserts the given record (using row and version) to all indexes and it  stores and returns the position of inserted
// record to each index
// IT SHOULD NOT CAUSE ANY EVENT TO BE FIRED
        internal int[] InsertRecordToIndexes(DataRow row, DataRowVersion  version) {
            int    indexCount          =  LiveIndexes.Count;
            int [] positionIndexes =  new int[indexCount];

            int recordNo = row.GetRecordFromVersion(version);
            DataViewRowState states = row.GetRecordState(recordNo);

            while (--indexCount >= 0) {
                if (row.HasVersion(version)) {
                    if ((states & indexes[indexCount].RecordStates) != DataViewRowState.None) {
                        positionIndexes [indexCount] = indexes[indexCount].InsertRecordToIndex(recordNo);
                    }
                    else {
                        positionIndexes [indexCount] = -1;
                    }
                }
            }
            return positionIndexes;
        }
Пример #7
0
// RemoveRecordFromIndexes removes the given record (using row and version) from all indexes and it  stores and returns the position of deleted
// record from each index
// IT SHOULD NOT CAUSE ANY EVENT TO BE FIRED
        internal int[] RemoveRecordFromIndexes(DataRow row, DataRowVersion  version) {
            int    indexCount          =  LiveIndexes.Count;
            int [] positionIndexes =  new int[indexCount];

            int recordNo = row.GetRecordFromVersion(version);
            DataViewRowState states = row.GetRecordState(recordNo);

            while (--indexCount >= 0) {
                if (row.HasVersion(version) && ((states & indexes[indexCount].RecordStates) != DataViewRowState.None)) {
                    int index = indexes[indexCount].GetIndex(recordNo);
                    if (index > -1) {
                        positionIndexes [indexCount] = index;
                        indexes[indexCount].DeleteRecordFromIndex(index); // this will delete the record from index and MUSt not fire event
                    }
                    else {
                        positionIndexes [indexCount] = -1; // this means record was not in index
                    }
                }
                else {
                    positionIndexes [indexCount] = -1; // this means record was not in index
                }
            }
            return positionIndexes;
        }
 internal override object Eval(DataRow row, DataRowVersion version)
 {
     if (!this.found)
     {
         throw ExprException.UnboundName(this.name);
     }
     if (row != null)
     {
         return this.column[row.GetRecordFromVersion(version)];
     }
     if (!this.IsTableConstant())
     {
         throw ExprException.UnboundName(this.name);
     }
     return this.column.DataExpression.Evaluate();
 }
Пример #9
0
        // Return the field value as a string. If the field value is NULL, then NULL is return.
        // If the column type is string and it's value is empty, then the empty string is returned.
        // If the column type is not string, or the column type is string and the value is not empty string, then a non-empty string is returned
        // This method does not throw any formatting exceptions, since we can always format the field value to a string.
        internal string GetColumnValueAsString(DataRow row, DataRowVersion version)
        {
            object objValue = this[row.GetRecordFromVersion(version)];

            if (DataStorage.IsObjectNull(objValue))
            {
                return null;
            }

            string value = ConvertObjectToXml(objValue);
            Debug.Assert(value != null);
            return value;
        }
Пример #10
0
        internal virtual void Evaluate(DataRow row, DataRowVersion version)
        {
#if DEBUG
            if (CompModSwitches.DataExpression.TraceVerbose)
            {
                Debug.WriteLine("Evaluate expression column Queue, version = " + version.ToString() + " for table " + owner.TableName);
            }
#endif
            Debug.Assert(columns != null, "Invalid dependensy list");
            Debug.Assert(row != null, "Invalid argument to Evaluate, row");
            for (int i = 0; i < columnCount; i++)
            {
                DataColumn col = columns[i];
                Debug.Assert(col.Computed, "Only computed columns should be in the queue.");

#if DEBUG
                if (CompModSwitches.DataExpression.TraceVerbose)
                {
                    Debug.WriteLine("Evaluate column " + col.ColumnName + " = " + col.DataExpression.ToString());
                }
#endif

                if (col.Table == null)
                {
                    continue;
                }

                if (col.Table != owner)
                {
                    // first if the column belongs to an other table we need to recalc it for each row in the foreing table

#if DEBUG
                    if (CompModSwitches.DataExpression.TraceVerbose)
                    {
                        Debug.WriteLine("the column belong to a different table %%%%%%%");
                    }
#endif
                    // we need to update all foreign table - NOPE, only those who are valid parents. ALTHOUGH we're skipping old parents right now... confirm.
                    DataRowVersion foreignVer = (version == DataRowVersion.Proposed) ? DataRowVersion.Default : version;

                    int parentRelationCount = owner.ParentRelations.Count;
                    for (int j = 0; j < parentRelationCount; j++)
                    {
                        DataRelation relation = owner.ParentRelations[j];
                        if (relation.ParentTable != col.Table)
                        {
                            continue;
                        }
                        DataRow parentRow = row.GetParentRow(relation, version);
                        if (parentRow != null)
                        {
                            col[parentRow.GetRecordFromVersion(foreignVer)] = col.DataExpression.Evaluate(parentRow, foreignVer);
                        }
                    }

                    int childRelationCount = owner.ChildRelations.Count;
                    for (int j = 0; j < childRelationCount; j++)
                    {
                        DataRelation relation = owner.ChildRelations[j];
                        if (relation.ChildTable != col.Table)
                        {
                            continue;
                        }
                        DataRow[] childRows = row.GetChildRows(relation, version);
                        for (int k = 0; k < childRows.Length; k++)
                        {
                            if (childRows[k] != null)
                            {
                                col[childRows[k].GetRecordFromVersion(foreignVer)] = col.DataExpression.Evaluate(childRows[k], foreignVer);
                            }
                        }
                    }
                }
                else if (col.DataExpression.HasLocalAggregate())
                {
                    // if column expression references a local Table aggregate we need to recalc it for the each row in the local table

                    DataRowVersion aggVersion = (version == DataRowVersion.Proposed) ? DataRowVersion.Default : version;
#if DEBUG
                    if (CompModSwitches.DataExpression.TraceVerbose)
                    {
                        Debug.WriteLine("it has local aggregate.");
                    }
#endif
                    bool   isConst = col.DataExpression.IsTableAggregate();
                    object val     = null;

                    if (isConst)
                    {
                        val = col.DataExpression.Evaluate(row, aggVersion);
                    }

                    DataRow[] rows = new DataRow[col.Table.Rows.Count];
                    col.Table.Rows.CopyTo(rows, 0);

                    for (int j = 0; j < rows.Length; j++)
                    {
                        if (!isConst)
                        {
                            val = col.DataExpression.Evaluate(rows[j], aggVersion);
                        }
                        col[rows[j].GetRecordFromVersion(aggVersion)] = val;
                    }
                }
                else
                {
                    col[row.GetRecordFromVersion(version)] = col.DataExpression.Evaluate(row, version);
                }
            }
        }
 internal void SilentlySetValue(DataRow dr, DataColumn dc, DataRowVersion version, object newValue)
 {
     int recordFromVersion = dr.GetRecordFromVersion(version);
     bool flag = false;
     if (DataStorage.IsTypeCustomType(dc.DataType) && (newValue != dc[recordFromVersion]))
     {
         flag = false;
     }
     else
     {
         flag = dc.CompareValueTo(recordFromVersion, newValue, true);
     }
     if (!flag)
     {
         int[] oldIndex = dr.Table.RemoveRecordFromIndexes(dr, version);
         dc.SetValue(recordFromVersion, newValue);
         int[] newIndex = dr.Table.InsertRecordToIndexes(dr, version);
         if (dr.HasVersion(version))
         {
             if (version != DataRowVersion.Original)
             {
                 dr.Table.RecordChanged(oldIndex, newIndex);
             }
             if (dc.dependentColumns != null)
             {
                 dc.Table.EvaluateDependentExpressions(dc.dependentColumns, dr, version, null);
             }
         }
     }
     dr.ResetLastChangedColumn();
 }
 internal int[] RemoveRecordFromIndexes(DataRow row, DataRowVersion version)
 {
     int count = this.LiveIndexes.Count;
     int[] numArray = new int[count];
     int recordFromVersion = row.GetRecordFromVersion(version);
     DataViewRowState recordState = row.GetRecordState(recordFromVersion);
     while (--count >= 0)
     {
         if (row.HasVersion(version) && ((recordState & this.indexes[count].RecordStates) != DataViewRowState.None))
         {
             int index = this.indexes[count].GetIndex(recordFromVersion);
             if (index > -1)
             {
                 numArray[count] = index;
                 this.indexes[count].DeleteRecordFromIndex(index);
             }
             else
             {
                 numArray[count] = -1;
             }
         }
         else
         {
             numArray[count] = -1;
         }
     }
     return numArray;
 }
 internal int[] InsertRecordToIndexes(DataRow row, DataRowVersion version)
 {
     int count = this.LiveIndexes.Count;
     int[] numArray = new int[count];
     int recordFromVersion = row.GetRecordFromVersion(version);
     DataViewRowState recordState = row.GetRecordState(recordFromVersion);
     while (--count >= 0)
     {
         if (row.HasVersion(version))
         {
             if ((recordState & this.indexes[count].RecordStates) != DataViewRowState.None)
             {
                 numArray[count] = this.indexes[count].InsertRecordToIndex(recordFromVersion);
             }
             else
             {
                 numArray[count] = -1;
             }
         }
     }
     return numArray;
 }