using System;
using System.Collections;
using System.Globalization;
+using System.Xml;
namespace System.Data {
/// <summary>
private int _rowId;
internal bool _inExpressionEvaluation = false;
+ private XmlDataDocument.XmlDataElement mappedElement;
+
#endregion
#region Constructors
this [dc] = dc.AutoIncrementValue();
}
_table.Columns.CollectionChanged += new System.ComponentModel.CollectionChangeEventHandler(CollectionChanged);
+
+ // create mapped XmlDataElement
+ DataSet ds = _table.DataSet;
+ if (ds != null && ds._xmlDataDocument != null)
+ mappedElement = new XmlDataDocument.XmlDataElement (this, _table.Prefix, _table.TableName, _table.Namespace, ds._xmlDataDocument);
}
}
else if(col.AutoIncrement == true && CanAccess(index,DataRowVersion.Default))
{
+ // AutoIncrement column is already filled,
+ // so it just need to return existing value.
newval = this [index];
-// newval = col.AutoIncrementValue ();
}
else
{
get { return _table; }
}
+ internal XmlDataDocument.XmlDataElement DataElement {
+ get { return mappedElement; }
+ set { mappedElement = value; }
+ }
+
/// <summary>
/// Gets and sets index of row. This is used from
/// XmlDataDocument.
for(int i = 0; i < columns.Count; i++){
string columnName = columns[i].ColumnName;
- int index = row.Table.Columns.IndexOf(columnName);
+ DataColumn column = row.Table.Columns[columnName];
//if a column with the same name exists in both rows copy the values
- if(index != -1) {
+ if(column != null) {
+ int index = column.Ordinal;
if (HasVersion(DataRowVersion.Original))
{
if (row.original == null)
row.original = new object[row.Table.Columns.Count];
- row.original[index] = row.SetColumnValue(original[i], Table.Columns[index], index);
+ row.original[index] = row.SetColumnValue(original[i], column, index);
}
if (HasVersion(DataRowVersion.Current))
{
if (row.current == null)
row.current = new object[row.Table.Columns.Count];
- row.current[index] = row.SetColumnValue(current[i], Table.Columns[index], index);
+ row.current[index] = row.SetColumnValue(current[i], column, index);
}
if (HasVersion(DataRowVersion.Proposed))
{
if (row.proposed == null)
row.proposed = new object[row.Table.Columns.Count];
- row.proposed[index] = row.SetColumnValue(proposed[i], Table.Columns[index], index);
+ row.proposed[index] = row.SetColumnValue(proposed[i], column, index);
}
//Saving the current value as the column value
}
- public void CollectionChanged(object sender, System.ComponentModel.CollectionChangeEventArgs args)
+ private void CollectionChanged(object sender, System.ComponentModel.CollectionChangeEventArgs args)
{
// if a column is added we hava to add an additional value the
// the priginal, current and propoed arrays.
int index = this.Table.Columns.Count - 1;
if (current != null)
{
- tmp = new object[current.Length + 1];
+ tmp = new object [index + 1];
Array.Copy (current, tmp, current.Length);
tmp[tmp.Length - 1] = SetColumnValue(null, this.Table.Columns[index], index);
current = tmp;
}
if (proposed != null)
{
- tmp = new object[proposed.Length + 1];
+ tmp = new object [index + 1];
Array.Copy (proposed, tmp, proposed.Length);
tmp[tmp.Length - 1] = SetColumnValue(null, this.Table.Columns[index], index);
proposed = tmp;
}
if(original != null)
{
- tmp = new object[original.Length + 1];
+ tmp = new object [index + 1];
Array.Copy (original, tmp, original.Length);
tmp[tmp.Length - 1] = SetColumnValue(null, this.Table.Columns[index], index);
original = tmp;
if (_nullConstraintViolation) {
if (proposed != null) {
for (int i = 0; i < proposed.Length; i++) {
- if (this[i] == DBNull.Value && !_table.Columns[i].AllowDBNull)
- throw new NoNullAllowedException(_nullConstraintMessage);
- }
+ if (this[i] == DBNull.Value && !_table.Columns[i].AllowDBNull)
+ throw new NoNullAllowedException(_nullConstraintMessage);
+ }
}
_nullConstraintViolation = false;
}