Skip to content
Ed Ball edited this page Oct 23, 2021 · 2 revisions

Command should not be used with an interpolated string; use CommandFormat instead.

Faithlife.Data has special support for formatted SQL, which should be used instead of passing a normal interpolated string to DbConnector.Command. Consider using DbConnector.CommandFormat instead.

Invalid:

var whereSql = visible ? "" : " where not deleted";
return connector.Command($"select count(*) from widgets{whereSql};").Query<long>();

Valid:

var whereSql = visible ? Sql.Empty : Sql.Raw(" where not deleted");
return connector.CommandFormat($"select count(*) from widgets{whereSql};").Query<long>();
Clone this wiki locally