[Mono-devel-list] [PATCH] Fix parsing of sort strings in DataTable
haisenko at webport.de
Mon Jul 18 08:55:18 EDT 2005
here's another patch for the System.Data namespace.
Explanation: you can give a DataTable a sort string (via the Sort property)
which can look like this: "columnName1 ASC" , "columnName1, columnName2 DESC"
or even "columnName1 ASC, columnName2 DESC".
If you want to specify column names that contain spaces you need to "escape"
them... by putting it inside square brackets like this: "[Column name with
The problem is that if someone uses a name starting with a "[" or ending with
a "]" as ColumnName for a DataColumn (e.g., "string2]"), and you give a
DataTable containing such a column a sort string a la "string2] ASC" then
Monos DataTable.ParseSortString throws an ArgumentException.
Unfortunately such a string is valid... and some developers really do name
their columns like that (let's not discuss about that ;-)
The attached patch fixes the behaviour of DataTable.ParseSortString. It also
allows (also valid) strings like "[string2]] ASC" (yes, I've tested against
MS .NET to make sure something like that is valid).
Webport IT-Services GmbH
mailto: haisenko at webport.de
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3408 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20050718/fe2e7918/attachment.bin
More information about the Mono-devel-list