W
William F. Robertson, Jr.
Either this is a bug, or it should be.
DataTable table = new DataTable();
table.Columns.Add( "Base1", typeof( string ) );
table.Columns.Add( "Base2", typeof( string ) );
//these will not run
Trace.Assert( table.Columns["Base1"] != null, "Base1 is null" );
Trace.Assert( table.Columns["Base2"] != null, "Base2 is null" );
Trace.Assert( table.Columns["base1"] != null, "base1 is null" );
Trace.Assert( table.Columns["base2"] != null, "base2 is null" );
table.Columns["Base1"].ColumnName = "newBase1";
//this will not display
Trace.Assert( table.Columns["newBase1"] != null, "newBase1 is null" );
//this will display
Trace.Assert( table.Columns["newbase1"] != null, "newbase1 is null" );
It seems the columns lose their case insensitivity when the ColumnName is
changed.
However the work around we came up with:
DataTable table = new DataTable();
table.Columns.Add( "Base1", typeof( string ) );
table.Columns.Add( "Base2", typeof( string ) );
table.Columns["Base1"].ColumnName = "newBase1";
//this will run
Trace.Assert( table.Columns["newbase1"] != null, "newbase is null" );
table = table.Clone();
//this will not run. The case insensitive is working again.
Trace.Assert( table.Columns["newbase1"] != null, "newbase is null" );
------
Is this the work around we should be doing? Is there another way? Is this
even a bug or am I missing something here?
Thanks,
bill
DataTable table = new DataTable();
table.Columns.Add( "Base1", typeof( string ) );
table.Columns.Add( "Base2", typeof( string ) );
//these will not run
Trace.Assert( table.Columns["Base1"] != null, "Base1 is null" );
Trace.Assert( table.Columns["Base2"] != null, "Base2 is null" );
Trace.Assert( table.Columns["base1"] != null, "base1 is null" );
Trace.Assert( table.Columns["base2"] != null, "base2 is null" );
table.Columns["Base1"].ColumnName = "newBase1";
//this will not display
Trace.Assert( table.Columns["newBase1"] != null, "newBase1 is null" );
//this will display
Trace.Assert( table.Columns["newbase1"] != null, "newbase1 is null" );
It seems the columns lose their case insensitivity when the ColumnName is
changed.
However the work around we came up with:
DataTable table = new DataTable();
table.Columns.Add( "Base1", typeof( string ) );
table.Columns.Add( "Base2", typeof( string ) );
table.Columns["Base1"].ColumnName = "newBase1";
//this will run
Trace.Assert( table.Columns["newbase1"] != null, "newbase is null" );
table = table.Clone();
//this will not run. The case insensitive is working again.
Trace.Assert( table.Columns["newbase1"] != null, "newbase is null" );
------
Is this the work around we should be doing? Is there another way? Is this
even a bug or am I missing something here?
Thanks,
bill