I did TDD against some existing stored procedures. They return XML, so I use LINQ to XML.
I am currently working on a test that will prove that the data is sorted correctly. The test passes through XML and creates an IEnumerable of an anonymous type containing three columns to be sorted. From this, he creates a second IEnumerable, sorting the first:
var sortedColumns = from g in columns orderby g.ColumnA ascending, g.ColumnB ascending, g.ColumnC ascending select g;
Finally, he claims that sorted columns are the same as unsorted ones using SequenceEquals.
The problem occurs when the database sort is different from the current sort. In particular, .NET places βW-β before βWaβ in column B.
Is there a way to sort in the same order as SQL Server random sort? If not, how will I sort in the same order as SQL_Latin1_General_CP1_CI_AS?
sorting sql-server linq-to-xml collation
John saunders
source share