Flatten using connection in GetMediaAttachments/SaveMediaAttachments

This commit is contained in:
Andrew Mahone 2019-11-04 10:28:33 -05:00
parent 4573fb5301
commit 0dde5e46df

View file

@ -6169,10 +6169,8 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
cmdText += " order by AttachmentIndex ASC";
using (var connection = GetConnection(true))
{
var list = new List<MediaAttachment>();
using var connection = GetConnection(true);
using (var statement = PrepareStatement(connection, cmdText))
{
statement.TryBind("@ItemId", query.ItemId.ToByteArray());
@ -6189,7 +6187,6 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
return list;
}
}
public void SaveMediaAttachments(Guid id, List<MediaAttachment> attachments, CancellationToken cancellationToken)
{
@ -6204,8 +6201,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
throw new ArgumentNullException(nameof(attachments));
}
using (var connection = GetConnection())
{
using var connection = GetConnection();
connection.RunInTransaction(db =>
{
var itemIdBlob = id.ToByteArray();
@ -6216,7 +6212,6 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
}, TransactionMode);
}
}
private void InsertMediaAttachments(byte[] idBlob, List<MediaAttachment> attachments, IDatabaseConnection db)
{