[Mono-list] [PATCH] DataRow.cs
Daniel Morgan
danmorg@sc.rr.com
Tue, 19 Nov 2002 15:15:10 -0500
Carlos,
Thank you for your patch. I have committed this fix to cvs for you.
Normally, patches should be created in the directory where the differences
have occurred via
cvs -z3 diff -u > mypatch
and attach that mypatch file to your email to mono-list.
This is mentioned at the web
page http://www.go-mono.com/ccvs.html
Daniel
-----Original Message-----
From: mono-list-admin@ximian.com [mailto:mono-list-admin@ximian.com]On
Behalf Of Carlos Guzmán Álvarez
Sent: Tuesday, November 19, 2002 2:40 PM
To: Mono-List
Subject: [Mono-list] [PATCH] DataRow.cs
Hello:
I´m having problems trying to make this:
schemaRow["BaseSchemaName"] = null;
SchemaRow is a Datarow instance and BaseSchemaName is defined as:
schema.Columns.Add("BaseSchemaName",System.Type.GetType("System.String"));
This works well on csc but not on mcs.
Here is the patch for this:
DataRow.cs
The change affects to the indexer:
public object this[DataColumn column]
Add this to line 99 (before bool objIsDBNull = value.Equals(DBNull.Value);):
value = (value == null) ? DBNull.value : value;
Here is the indexer changed:
public object this[DataColumn column] {
[MonoTODO] //FIXME: will return different values depending on DataRowState
get { return this[column, DataRowVersion.Current]; }
[MonoTODO]
set {
// The new line
value = (value == null) ? DBNull.value : value;
bool objIsDBNull = value.Equals(DBNull.Value);
if (column == null)
throw new ArgumentNullException ();
int columnIndex = _table.Columns.IndexOf (column);
if (columnIndex == -1)
throw new ArgumentException ();
if(column.DataType != value.GetType ()) {
if(objIsDBNull == true && column.AllowDBNull == false)
throw new InvalidCastException ();
//else if(objIsDBNull == false)
// throw new InvalidCastException ();
}
if (rowState == DataRowState.Deleted)
throw new DeletedRowInaccessibleException ();
//MS Implementation doesn't seem to create the proposed or original
//set of values when a datarow has just been created or added to the
//DataTable and AcceptChanges() has not been called yet.
if(rowState == DataRowState.Detached || rowState == DataRowState.Added) {
if(objIsDBNull)
current[columnIndex] = DBNull.Value;
else
current[columnIndex] = value;
}
else {
BeginEdit (); // implicitly called
rowState = DataRowState.Modified;
if(objIsDBNull)
proposed[columnIndex] = DBNull.Value;
else
proposed[columnIndex] = value;
}
//Don't know if this is the rigth thing to do,
//but it fixes my test. I believe the MS docs only say this
//method is implicitly called when calling AcceptChanges()
// EndEdit (); // is this the right thing to do?
}
}
Best regards
Carlos Guzmán Álvarez
Vigo - Spain
_______________________________________________
Mono-list maillist - Mono-list@ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list