linqlinq.js

How can replace all case in value of column using linq.js?


I using linq.js and i want replace single quotes when searching data. This my code.

var list = [
            { a: "50", b: 4, c: 1 },
            { a: "60", b: 3, c: 7 },
            { a: "'540'", b: 3, c: 3 }
           ];
var val = "'540'";
val = val.replace(/'/g, "'");
var res = Enumerable.From(list).Where("($.a).replace(\"'\",\"'\")=='" + val + "'").ToArray();

If there is only 1 single quote in the data, it works.
But if there are 2 single quote in it, it can't search.


Solution

  • Oh, linq.js the same code in javascript. I have to use regex to replace: It is ok , if i change to :

     var res = Enumerable.From(list).Where("($.a).replace(\/'\/g,\"'\")=='" + val + "'").ToArray();