You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Framework/Connected.Data/Sql/DatabaseWriter.cs

39 lines
744 B

using Connected.Data.Storage;
using Connected.Entities.Storage;
namespace Connected.Data.Sql;
internal class DatabaseWriter : DatabaseCommand, IStorageWriter
{
public DatabaseWriter(IStorageOperation operation, IStorageConnection connection)
: base(operation, connection)
{
}
public async Task<int> Execute()
{
if (Connection is null)
return -1;
try
{
var recordsAffected = await Connection.Execute(this);
if (Connection.Behavior == StorageConnectionMode.Isolated)
await Connection.Commit();
return recordsAffected;
}
finally
{
if (Connection.Behavior == StorageConnectionMode.Isolated)
{
await Connection.Close();
await Connection.DisposeAsync();
Connection = null;
}
}
}
}