using System.Collections.Immutable; using System.Data; using Connected.Data.Storage; using Connected.Entities.Storage; namespace Connected.ServiceModel.Client.Data; internal sealed class TableReader : TableCommand, IStorageReader { public TableReader(IStorageOperation operation, IStorageConnection connection) : base(operation, connection) { } public async Task?> Query() { if (Connection is null) return default; try { var result = await Connection.Query(this); if (Connection.Behavior == StorageConnectionMode.Isolated) await Connection.Commit(); return result; } finally { if (Connection.Behavior == StorageConnectionMode.Isolated) { await Connection.Close(); await Connection.DisposeAsync(); Connection = null; } } } public async Task Select() { try { if (Connection is null) return default; var result = await Connection.Select(this); if (Connection.Behavior == StorageConnectionMode.Isolated) await Connection.Commit(); return result; } finally { if (Connection.Behavior == StorageConnectionMode.Isolated) { await Connection.Close(); await Connection.DisposeAsync(); Connection = null; } } } public async Task OpenReader() { if (Connection is null) return default; return await Connection.OpenReader(this); } }