using System.Data;
using Connected.ServiceModel.Client.Data.Remote;
namespace Connected.ServiceModel.Client.Data;
///
/// Represents the REST connection to the TomPIT.connected Table Service.
///
internal sealed class TableConnection : IDbConnection
{
public TableConnection(RemoteTableService tables, string connectionString)
{
Tables = tables;
ConnectionString = connectionString;
}
public RemoteTableService Tables { get; }
///
/// The connection string (URL) used when performing the requests.
///
public string ConnectionString { get; set; }
///
/// The request timeout in seconds.
///
public int ConnectionTimeout => 120;
///
/// The database (partition) on the server to be used.
///
public string Database { get; private set; }
///
/// The connection state. It's always open since it's a stateless connection.
///
public ConnectionState State => ConnectionState.Open;
///
/// Starts the new storage transaction.
///
/// A new .
public IDbTransaction BeginTransaction()
{
return new TableTransaction(this);
}
///
/// Starts the new storage transaction.
///
/// The isolation level. This property is ignored on this connection since
/// it's always .
/// A new .
public IDbTransaction BeginTransaction(IsolationLevel il)
{
return BeginTransaction();
}
///
/// The database is actually the Partition on the remote service. Calling this method
/// changes the partition to be used on the remote.
///
/// The partition name. It is created if it doesn't exist.
public void ChangeDatabase(string databaseName)
{
Database = databaseName;
}
///
/// This method completes the connection by calling
/// if has not been called.
///
public void Close()
{
}
public IDbCommand CreateCommand()
{
return new TableDataCommand(Tables);
}
public void Dispose()
{
}
///
/// This method doesn't do anything since the connection is stateless any is theoretically
/// always in open state.
///
public void Open()
{
}
}