I would like to know if there is a function to correctly escape string literals for filter expressions. e.g.:
DataTable.Select(String.Format("[name] = '{0}'", MyName))
If MyName contains ' or a number of other key characters an exception is generated. The Microsoft documentation indicates that these charaters should be correctly escaped, however there is a bit of confusion on how this is to be done.
I have tried replacing ' with ' and also ['] as indicated in the documentation, however the query still fails.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…