I've been doing some TDD against some existing stored procedures. They return XML, so I've been using LINQ to XML.
At the moment, I'm working on a test that will prove that the data have been sorted properly. The test navigates through the XML, and creates an IEnumerable of an anonymous type containing the three columns that should be sorted. From that, it creates a second IEnumerable by sorting the first:
var sortedColumns = from g in columns
orderby g.ColumnA ascending,
g.ColumnB ascending,
g.ColumnC ascending
select g;
Finally, it asserts that the sorted colums are the same as the unsorted ones using SequenceEquals.
The problem comes when the database collation differs from the current collation. In particular, .NET is placing "W-" before "Wa" in ColumnB.
Is there a way to sort in the same order as an arbitrary SQL Server collation? If not, then how would I sort in the same order as SQL_Latin1_General_CP1_CI_AS?