2

I am using a LINQ query to retrieve product SKUs. The problem is that lgVM670VG is different from lgVM670Vg; the query will return the result no matter what (the actual SKU is lgVM670VG).

SKU currentSKU = new SKU();
SKUDataContext dcSKU = new SKUDataContext();
var skuQuery =
    (from s in dcSKU.SKUs
     where s.SKU1 == strSKU
     orderby s.SKU1
     select s).SingleOrDefault();
CodeCaster
  • 147,647
  • 23
  • 218
  • 272
user1698144
  • 754
  • 4
  • 13
  • 36
  • Duplicate found by following search - http://www.bing.com/search?q=case+insensitive+linq+sql – Alexei Levenkov Dec 13 '13 at 18:31
  • 1
    _"The problem is that `...G` is different from `...g`"_ - so you want a case **sensitive** search. See @Johnny5's answer, set the proper collation, or see [this answer](http://stackoverflow.com/a/5416339/266143) in [making Linq case sensitive](http://stackoverflow.com/questions/5416254/making-linq-case-sensitive), the duplicate mentioned here is incorrect. – CodeCaster Dec 13 '13 at 18:41

1 Answers1

1

Your best bet may be to set a case sensitive collation on your sql server.

see this question for examle.

Community
  • 1
  • 1
Johnny5
  • 6,664
  • 3
  • 45
  • 78