2

I am a bit in a pickle. From all the documentation I read about StringComparison in .Net the InvariantCulture should select both "Kęstutis" and "Kestutis" when filter is "ke"

.Where(fp => filter == null || 
    (fp.RealName.StartsWith(filter, StringComparison.InvariantCultureIgnoreCase)))

but it still forces me to enter language-specific letters.

I am not sure if it's important, but the database is Ms SQL 2012 Express.

Any ideas?

  • Well, it also doesn't work with many other `dialects` of `e` like `é`, `è`,`ẻ`, `ẽ`, `ẹ`, `ê` – King King Oct 07 '13 at 16:37
  • @KingKing So what is the point of InvariantCulture option? – Alireza Oct 07 '13 at 16:41
  • @Alireza well, as documented it should have worked but for some strange reason it didn't, I'm not sure why. – King King Oct 07 '13 at 16:43
  • 1
    Somebody call Jon Skeet – Alireza Oct 07 '13 at 16:44
  • Where did you read that InvariantCulture was supposed to work that way? To my knowledge InvariantCulture is not meant for that at all. It is simply meant to provide a consistent culture for areas of your application which should not behave differently based on the current thread culture. For example, you may be saving dates in an XML file as a string and instead of writing both the Date and the Culture you may want to write the Date as InvariantCulture and read the Date as InvariantCulture. Then in the UI you can convert it to the local culture. – Trevor Elliott Oct 07 '13 at 16:52
  • Otherwise if you just wrote the DateTime.ToString() to a file and did DateTime.Parse(str) later, then you would throw an exception if the file was written as a different culture thread than it was read and that culture was an incompatible format. – Trevor Elliott Oct 07 '13 at 16:55

1 Answers1

0

This is what SQL Server string collation is about. You can set the Collation on the Table-Column.

Aron
  • 15,464
  • 3
  • 31
  • 64