I know that we should never do this:
string select = "SELECT * FROM table1 ";
string where = "WHERE Name = '" + name + "' ";
string sql = select + where;
due to SQL injection, because the name may contain char 'due to another 100 reasons. But now I have to do something similar. I have Dictionary<string, object>, the data of which is as follows:
Key(string) Value(object)
"Name" "Bob"
"ID" 10092L
"Birthday" 1980-05-07 00:00:00
"Salary" 5000.5m
I want an easy way to get all the elements in a dictionary assembled in String, like a where statement:
Name = 'Bob' and ID = 10092 and Birthday = '1980-05-07 00:00:00' and Salary = 5000.5
String and DateTime are quoted using ', but note that the name may be O'Neal. Is there a simple implementation? Enter the dictionary and return the string as a result.
, , , , . , WHERE.