using System.Text.RegularExpressions;
using System.Collections.Generic;
string strQuery = "Select c.car.value, c.like.model, c.color.in[0] order by c.price.on";
Console.WriteLine(strQuery);
string strQueryOk = ReplaceReservedWord(strQuery);
Console.WriteLine(strQueryOk);
public string ReplaceReservedWord(string strQuery)
string pattern = @"\.(value|top|where|in|on|like)\w*";
var replacements = Regex.Matches(strQuery, pattern)
.Select(m => new KeyValuePair<string, string>(m.Value, "['"+m.Value.Replace(".", "")+"']"));
string queryString = replacements.Aggregate(strQuery, (current, replacement) =>
current.Replace(replacement.Key, replacement.Value));