Flatten using connection in GetMediaAttachments/SaveMediaAttachments

pull/1838/head
Andrew Mahone 5 years ago
parent 4573fb5301
commit 0dde5e46df

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

Loading…
Cancel
Save