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