[Mono-devel-list] Case-sensitivity of Data Collections

Aleksey Demakov avd at openlinksw.com
Wed Mar 5 15:20:13 EST 2003


Hi,

I found that various collections from System.Data don't
follow the case-sensitivity rules defined in MS docs.

This is from DataTable description:

 >When accessing DataTable objects, note that they are conditionally 
 >case-sensitive. For example, if one DataTable is named "mydatatable" 
 >and another is named "Mydatatable", a string used to search for one of 
 >the tables is regarded as case-sensitive. However, if "mydatatable" 
 >exists and "Mydatatable" does not, the search string is regarded as 
 >case-insensitive.

This conditional case-sensitivity applies to DataTableCollection,
DataColumnCollection, DataRelationCollection, ConstraintCollection
(see below).

I've noticed that Mono ContstaraintCollection attempts to do something
like this but others don't.

What ADO.NET maintainers think about this? I can start doing this stuff
now.

Regards,
Aleksey

----------------------------------------------------------

Programming with the .NET Framework -> Accessing Data with ADO.NET
-> Creating and Using DataSets -> Adding a DataTable to a DataSet
-> Case Sensitivity

References by name to tables and relations in a DataSet are 
case-sensitive. Two or more tables or relations can exist in a DataSet 
that have the same name, but that differ in case. For example you can 
have Table1 and table1. In this situation, a reference to one of the 
tables by name must match the case of the table name exactly, otherwise 
an exception is thrown. For example, if the DataSet myDS contains tables 
Table1 and table1, you would reference Table1 by name as 
myDS.Tables["Table1"], and table1 as myDS.Tables ["table1"]. Attempting 
to reference either of the tables as myDS.Tables ["TABLE1"] would 
generate an exception.

The case-sensitivity rule does not apply if only one table or relation 
exists with a particular name. That is, if no other table or relation 
object in the DataSet matches the name of that particular table or 
relation object, even by a difference in case, you can reference the 
object by name using any case and no exception is thrown. For example, 
if the DataSet has only Table1, you can reference it using 
myDS.Tables["TABLE1"].

The CaseSensitive property of the DataSet does not affect this behavior. 
The CaseSensitive property applies to the data in the DataSet and 
affects sorting, searching, filtering, enforcing constraints, and so on. 
References to the tables or relations in a DataSet are not affected by 
the CaseSensitive property.

----------------------------------------------------------

Programming with the .NET Framework -> Accessing Data with ADO.NET ->
-> Creating and Using DataTables -> Defining the Schema of a DataTable
-> Case Sensitivity

References by name to columns, relations, and constraints in a table are 
case-sensitive. Two or more columns, relations, or constraints can exist 
in a table that have the same name, but that differ in case. For example 
you can have Col1 and col1. In this situation a reference to one of the 
columns by name must match the case of the column name exactly, 
otherwise an exception is thrown. For example, if the table myTable 
contains the columns Col1 and col1, you would reference Col1 by name as 
myTable.Columns["Col1"], and col1 as myTable.Columns["col1"]. Attempting 
to reference either of the columns as myTable.Columns["COL1"] would 
generate an exception.

The case-sensitivity rule does not apply if only one column, relation, 
or constraint exists with a particular name. That is, if no other 
column, relation, or constraint object in the table matches the name of 
that particular column, relation, or constraint object, even by a 
difference in case, you may reference the object by name using any case 
and no exception is thrown. For example, if the table has only Col1, you 
can reference it using my.Columns["COL1"].

The CaseSensitive property of the DataTable does not affect this 
behavior. The CaseSensitive property applies to the data in the table 
and affects sorting, searching, filtering, enforcing constraints, and so 
on. References to the columns, relations, and constraints in a table are 
not affected by the CaseSensitive property.






More information about the Mono-devel-list mailing list