Added extension for key/value querying
This commit is contained in:
parent
a5550ad3f7
commit
c2f52cec07
1 changed files with 14 additions and 0 deletions
|
|
@ -52,6 +52,20 @@ namespace TShockAPI.DB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static QueryResult QueryReaderDict(this IDbConnection olddb, string query, Dictionary<string, object> values)
|
||||||
|
{
|
||||||
|
var db = olddb.CloneEx();
|
||||||
|
db.Open();
|
||||||
|
using (var com = db.CreateCommand())
|
||||||
|
{
|
||||||
|
com.CommandText = query;
|
||||||
|
foreach(var kv in values)
|
||||||
|
com.AddParameter("@" + kv.Key, kv.Value);
|
||||||
|
|
||||||
|
return new QueryResult(db, com.ExecuteReader());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static IDbDataParameter AddParameter(this IDbCommand command, string name, object data)
|
public static IDbDataParameter AddParameter(this IDbCommand command, string name, object data)
|
||||||
{
|
{
|
||||||
var parm = command.CreateParameter();
|
var parm = command.CreateParameter();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue