Json.net Like queries

Aug 16, 2012 at 1:15 PM

Hi guys, 

I use XML and SqlClient today, but want to change it to Linq and Json.

For that i used newtonsoft Json.net but i have some problems.

i like to create a linq query like this in sql ... WHERE Name = '%de%rk%' and find the name "Denmark"...

 

Can anyone help me with that?

 

This code find only one word in my string:

String strJSONdata = System.IO.File.ReadAllText("D:\\huhu.txt"); 

            //JSON LOOP
            {
                var jsreader = new Newtonsoft.Json.JsonTextReader(new System.IO.StringReader(strJSONdata));
                var json = (Newtonsoft.Json.Linq.JObject)new Newtonsoft.Json.JsonSerializer().Deserialize(jsreader);
                var tableRows = from p in json["folders"] where System.Text.RegularExpressions.Regex.IsMatch(p["name"].ToString().ToLower(), txtId.Text)
                                select new
                                {
                                    id = (string)p["id"],
                                    name = (string)p["name"]
                                };
                foreach (var act in tableRows)
                {
                    if (act.name != "")
                    {
                        lbFolder.Items.Add(act.name);
                    }
                }
            }