Switch to Microsoft.Data.Sqlite for arm64
There is a slight change the the way QueryResult works in order to satisfy the variances in the new library. Disposing of the command with the reader appears to solve this, and hopefully, with minimal impact to plugins.
This commit is contained in:
parent
699047d119
commit
c063aabbc0
4 changed files with 26 additions and 14 deletions
|
|
@ -65,13 +65,13 @@ namespace TShockAPI.DB
|
|||
try
|
||||
{
|
||||
db.Open();
|
||||
using (var com = db.CreateCommand())
|
||||
var com = db.CreateCommand(); // this will be disposed via the QueryResult instance
|
||||
{
|
||||
com.CommandText = query;
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
com.AddParameter("@" + i, args[i]);
|
||||
|
||||
return new QueryResult(db, com.ExecuteReader());
|
||||
return new QueryResult(db, com.ExecuteReader(), com);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -117,13 +117,13 @@ namespace TShockAPI.DB
|
|||
{
|
||||
var db = olddb.CloneEx();
|
||||
db.Open();
|
||||
using (var com = db.CreateCommand())
|
||||
var com = db.CreateCommand(); // this will be disposed via the QueryResult instance
|
||||
{
|
||||
com.CommandText = query;
|
||||
foreach (var kv in values)
|
||||
com.AddParameter("@" + kv.Key, kv.Value);
|
||||
|
||||
return new QueryResult(db, com.ExecuteReader());
|
||||
return new QueryResult(db, com.ExecuteReader(), com);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -274,11 +274,13 @@ namespace TShockAPI.DB
|
|||
{
|
||||
public IDbConnection Connection { get; protected set; }
|
||||
public IDataReader Reader { get; protected set; }
|
||||
public IDbCommand Command { get; protected set; }
|
||||
|
||||
public QueryResult(IDbConnection conn, IDataReader reader)
|
||||
public QueryResult(IDbConnection conn, IDataReader reader, IDbCommand command)
|
||||
{
|
||||
Connection = conn;
|
||||
Reader = reader;
|
||||
Command = command;
|
||||
}
|
||||
|
||||
~QueryResult()
|
||||
|
|
@ -301,6 +303,11 @@ namespace TShockAPI.DB
|
|||
Reader.Dispose();
|
||||
Reader = null;
|
||||
}
|
||||
if (Command != null)
|
||||
{
|
||||
Command.Dispose();
|
||||
Command = null;
|
||||
}
|
||||
if (Connection != null)
|
||||
{
|
||||
Connection.Dispose();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue