Skip to content

Commit ee45333

Browse files
more docs
1 parent 52385b6 commit ee45333

File tree

10 files changed

+481
-7
lines changed

10 files changed

+481
-7
lines changed

src/Ydb.Sdk/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- XML documentation for all public APIs in `Ydb.Sdk`.
1+
- Added XML documentation for all public APIs in `Ydb.Sdk`.
22
- Feat ADO.NET: Added dispose timeout (10 seconds) to `PoolingSessionSource`.
33
- Feat ADO.NET: Added `EnableImplicitSession` to support implicit sessions.
44

src/Ydb.Sdk/src/Ado/Schema/YdbTableStats.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Ydb.Sdk.Ado.Schema;
22

3-
public class YdbTableStats
3+
internal class YdbTableStats
44
{
55
public YdbTableStats(Table.TableStats tableStats)
66
{

src/Ydb.Sdk/src/Ado/Transaction/TransactionMode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Ydb.Sdk.Ado;
1010
/// for database operations within a transaction.
1111
///
1212
/// For more information about YDB transaction modes, see:
13-
/// <see href="https://ydb.tech/docs/en/concepts/transactions">YDB Transactions Documentation</see>
13+
/// <see href="https://ydb.tech/docs/en/concepts/transactions">YDB Transactions Documentation</see>.
1414
/// </remarks>
1515
public enum TransactionMode
1616
{

src/Ydb.Sdk/src/Ado/YdbConnectionStringBuilder.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ namespace Ydb.Sdk.Ado;
1515
/// <remarks>
1616
/// YdbConnectionStringBuilder provides strongly-typed properties for building YDB connection strings.
1717
/// It supports all standard ADO.NET connection string parameters plus YDB-specific options.
18+
///
19+
/// For more information about YDB, see:
20+
/// <see href="https://ydb.tech/docs">YDB Documentation</see>.
1821
/// </remarks>
1922
public sealed class YdbConnectionStringBuilder : DbConnectionStringBuilder
2023
{

src/Ydb.Sdk/src/Ado/YdbDataSource.cs

Lines changed: 235 additions & 0 deletions
Large diffs are not rendered by default.

src/Ydb.Sdk/src/Ado/YdbDataSourceBuilder.cs

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,87 @@
22

33
namespace Ydb.Sdk.Ado;
44

5+
/// <summary>
6+
/// Provides a simple way to create and configure a <see cref="YdbDataSource"/>.
7+
/// </summary>
8+
/// <remarks>
9+
/// YdbDataSourceBuilder provides a fluent interface for configuring connection strings
10+
/// and retry policies before building a YdbDataSource instance. It supports both
11+
/// string-based and strongly-typed connection string configuration.
12+
///
13+
/// For more information about YDB, see:
14+
/// <see href="https://ydb.tech/docs">YDB Documentation</see>.
15+
/// </remarks>
516
public class YdbDataSourceBuilder
617
{
18+
/// <summary>
19+
/// Initializes a new instance of the <see cref="YdbDataSourceBuilder"/> class with default settings.
20+
/// </summary>
21+
/// <remarks>
22+
/// Creates a new builder with default connection string and retry policy settings.
23+
/// </remarks>
724
public YdbDataSourceBuilder()
825
{
926
ConnectionStringBuilder = new YdbConnectionStringBuilder();
1027
}
1128

29+
/// <summary>
30+
/// Initializes a new instance of the <see cref="YdbDataSourceBuilder"/> class with the specified connection string.
31+
/// </summary>
32+
/// <param name="connectionString">The connection string to use for the data source.</param>
33+
/// <remarks>
34+
/// Creates a new builder with the specified connection string and default retry policy.
35+
/// </remarks>
1236
public YdbDataSourceBuilder(string connectionString)
1337
{
1438
ConnectionStringBuilder = new YdbConnectionStringBuilder(connectionString);
1539
}
1640

41+
/// <summary>
42+
/// Initializes a new instance of the <see cref="YdbDataSourceBuilder"/> class with the specified connection string builder.
43+
/// </summary>
44+
/// <param name="connectionStringBuilder">The connection string builder to use for the data source.</param>
45+
/// <remarks>
46+
/// Creates a new builder with the specified connection string builder and default retry policy.
47+
/// </remarks>
1748
public YdbDataSourceBuilder(YdbConnectionStringBuilder connectionStringBuilder)
1849
{
1950
ConnectionStringBuilder = connectionStringBuilder;
2051
}
2152

2253
/// <summary>
23-
/// A connection string builder that can be used to configure the connection string on the builder.
54+
/// Gets the connection string builder that can be used to configure the connection string.
2455
/// </summary>
56+
/// <remarks>
57+
/// Provides strongly-typed properties for configuring YDB connection parameters.
58+
/// Changes to this builder will be reflected in the built data source.
59+
/// </remarks>
2560
public YdbConnectionStringBuilder ConnectionStringBuilder { get; }
2661

2762
/// <summary>
28-
/// Returns the connection string, as currently configured on the builder.
63+
/// Gets the connection string as currently configured on the builder.
2964
/// </summary>
65+
/// <remarks>
66+
/// Returns the current connection string based on the configuration in the ConnectionStringBuilder.
67+
/// </remarks>
3068
public string ConnectionString => ConnectionStringBuilder.ConnectionString;
3169

70+
/// <summary>
71+
/// Gets or sets the retry policy for the data source.
72+
/// </summary>
73+
/// <remarks>
74+
/// Specifies the retry policy to use for handling transient failures.
75+
/// Default value is a YdbRetryPolicy with default configuration.
76+
/// </remarks>
3277
public IRetryPolicy RetryPolicy { get; set; } = new YdbRetryPolicy(YdbRetryPolicyConfig.Default);
3378

79+
/// <summary>
80+
/// Builds a new <see cref="YdbDataSource"/> instance with the current configuration.
81+
/// </summary>
82+
/// <returns>A new YdbDataSource instance configured with the current settings.</returns>
83+
/// <remarks>
84+
/// Creates a new data source with the configured connection string and retry policy.
85+
/// The builder can be reused to create multiple data sources with different configurations.
86+
/// </remarks>
3487
public YdbDataSource Build() => new(this);
3588
}

src/Ydb.Sdk/src/Ado/YdbProviderFactory.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,78 @@
22

33
namespace Ydb.Sdk.Ado;
44

5+
/// <summary>
6+
/// Represents a set of methods for creating instances of a provider's implementation of the data source classes.
7+
/// </summary>
8+
/// <remarks>
9+
/// YdbProviderFactory is the factory class for creating YDB-specific data source objects.
10+
/// It provides methods to create connections, commands, parameters, and other ADO.NET objects
11+
/// that are specific to the YDB database provider.
12+
///
13+
/// For more information about YDB, see:
14+
/// <see href="https://ydb.tech/docs">YDB Documentation</see>.
15+
/// </remarks>
516
public class YdbProviderFactory : DbProviderFactory
617
{
18+
/// <summary>
19+
/// Gets the singleton instance of the YdbProviderFactory.
20+
/// </summary>
21+
/// <remarks>
22+
/// This static instance can be used to create YDB-specific ADO.NET objects
23+
/// without instantiating the factory class directly.
24+
/// </remarks>
725
public static readonly YdbProviderFactory Instance = new();
826

27+
/// <summary>
28+
/// Returns a strongly typed <see cref="YdbCommand"/> object.
29+
/// </summary>
30+
/// <returns>A new instance of <see cref="YdbCommand"/>.</returns>
31+
/// <remarks>
32+
/// Creates a new YDB command object that can be used to execute SQL statements
33+
/// and stored procedures against a YDB database.
34+
/// </remarks>
935
public override YdbCommand CreateCommand() => new();
1036

37+
/// <summary>
38+
/// Returns a strongly typed <see cref="YdbConnection"/> object.
39+
/// </summary>
40+
/// <returns>A new instance of <see cref="YdbConnection"/>.</returns>
41+
/// <remarks>
42+
/// Creates a new YDB connection object that can be used to connect to a YDB database.
43+
/// The connection must be opened before it can be used for database operations.
44+
/// </remarks>
1145
public override YdbConnection CreateConnection() => new();
1246

47+
/// <summary>
48+
/// Returns a strongly typed <see cref="YdbConnectionStringBuilder"/> object.
49+
/// </summary>
50+
/// <returns>A new instance of <see cref="YdbConnectionStringBuilder"/>.</returns>
51+
/// <remarks>
52+
/// Creates a new YDB connection string builder that provides strongly-typed properties
53+
/// for building YDB connection strings with validation and IntelliSense support.
54+
/// </remarks>
1355
public override YdbConnectionStringBuilder CreateConnectionStringBuilder() => new();
1456

57+
/// <summary>
58+
/// Returns a strongly typed <see cref="YdbParameter"/> object.
59+
/// </summary>
60+
/// <returns>A new instance of <see cref="YdbParameter"/>.</returns>
61+
/// <remarks>
62+
/// Creates a new YDB parameter object that can be used to pass parameters
63+
/// to YDB commands. The parameter supports YDB-specific data types and features.
64+
/// </remarks>
1565
public override DbParameter CreateParameter() => new YdbParameter();
1666

1767
#if NET7_0_OR_GREATER
68+
/// <summary>
69+
/// Returns a strongly typed <see cref="YdbDataSource"/> object.
70+
/// </summary>
71+
/// <param name="connectionString">The connection string to use for the data source.</param>
72+
/// <returns>A new instance of <see cref="YdbDataSource"/> with the specified connection string.</returns>
73+
/// <remarks>
74+
/// Creates a new YDB data source object that provides a modern, lightweight way to work with YDB.
75+
/// The data source is available only in .NET 7.0 and later versions.
76+
/// </remarks>
1877
public override YdbDataSource CreateDataSource(string connectionString) => new();
1978
#endif
2079
}

src/Ydb.Sdk/src/Ado/YdbTransaction.cs

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55

66
namespace Ydb.Sdk.Ado;
77

8+
/// <summary>
9+
/// Represents a YDB transaction. This class cannot be inherited.
10+
/// </summary>
11+
/// <remarks>
12+
/// YdbTransaction represents a database transaction in YDB. It provides methods to commit or rollback
13+
/// changes made within the transaction. The transaction mode determines the isolation level and
14+
/// consistency guarantees.
15+
///
16+
/// For more information about YDB transactions, see:
17+
/// <see href="https://ydb.tech/docs/en/concepts/transactions">YDB Transactions Documentation</see>.
18+
/// </remarks>
819
public sealed class YdbTransaction : DbTransaction
920
{
1021
private readonly TransactionMode _transactionMode;
@@ -13,9 +24,32 @@ public sealed class YdbTransaction : DbTransaction
1324
private YdbConnection? _ydbConnection;
1425
private bool _isDisposed;
1526

27+
/// <summary>
28+
/// Gets or sets the transaction identifier.
29+
/// </summary>
30+
/// <remarks>
31+
/// The transaction ID is assigned by YDB when the transaction is started.
32+
/// This property is used internally for transaction management.
33+
/// </remarks>
1634
internal string? TxId { get; set; }
35+
36+
/// <summary>
37+
/// Gets a value indicating whether the transaction has been completed.
38+
/// </summary>
39+
/// <remarks>
40+
/// A transaction is considered completed when it has been committed, rolled back, or failed.
41+
/// Once completed, the transaction cannot be used for further operations.
42+
/// </remarks>
1743
internal bool Completed { get; private set; }
1844

45+
/// <summary>
46+
/// Gets or sets a value indicating whether the transaction has failed.
47+
/// </summary>
48+
/// <remarks>
49+
/// When true, indicates that the transaction has been rolled back by the server.
50+
/// A failed transaction cannot be committed. The <see cref="Rollback"/> method
51+
/// can be called to mark the transaction as completed.
52+
/// </remarks>
1953
internal bool Failed
2054
{
2155
private get => _failed;
@@ -26,6 +60,13 @@ internal bool Failed
2660
}
2761
}
2862

63+
/// <summary>
64+
/// Gets the transaction control for YDB operations.
65+
/// </summary>
66+
/// <remarks>
67+
/// Returns null if the transaction is completed, otherwise returns the appropriate
68+
/// transaction control based on whether the transaction has been started.
69+
/// </remarks>
2970
internal TransactionControl? TransactionControl => Completed
3071
? null
3172
: TxId == null
@@ -38,13 +79,65 @@ internal YdbTransaction(YdbConnection ydbConnection, TransactionMode transaction
3879
_transactionMode = transactionMode;
3980
}
4081

82+
/// <summary>
83+
/// Commits the database transaction.
84+
/// </summary>
85+
/// <exception cref="InvalidOperationException">
86+
/// Thrown when the transaction has already been completed or the connection is closed.
87+
/// </exception>
88+
/// <exception cref="YdbOperationInProgressException">
89+
/// Thrown when another operation is in progress on the connection.
90+
/// </exception>
91+
/// <exception cref="YdbException">
92+
/// Thrown when the commit operation fails.
93+
/// </exception>
4194
public override void Commit() => CommitAsync().GetAwaiter().GetResult();
4295

96+
/// <summary>
97+
/// Asynchronously commits the database transaction.
98+
/// </summary>
99+
/// <param name="cancellationToken">A token to cancel the operation.</param>
100+
/// <returns>A task representing the asynchronous operation.</returns>
101+
/// <exception cref="InvalidOperationException">
102+
/// Thrown when the transaction has already been completed or the connection is closed.
103+
/// </exception>
104+
/// <exception cref="YdbOperationInProgressException">
105+
/// Thrown when another operation is in progress on the connection.
106+
/// </exception>
107+
/// <exception cref="YdbException">
108+
/// Thrown when the commit operation fails.
109+
/// </exception>
43110
public override async Task CommitAsync(CancellationToken cancellationToken = new()) =>
44111
await FinishTransaction(txId => DbConnection!.Session.CommitTransaction(txId, cancellationToken));
45112

113+
/// <summary>
114+
/// Rolls back the database transaction.
115+
/// </summary>
116+
/// <exception cref="InvalidOperationException">
117+
/// Thrown when the transaction has already been completed or the connection is closed.
118+
/// </exception>
119+
/// <exception cref="YdbOperationInProgressException">
120+
/// Thrown when another operation is in progress on the connection.
121+
/// </exception>
122+
/// <exception cref="YdbException">
123+
/// Thrown when the rollback operation fails.
124+
/// </exception>
46125
public override void Rollback() => RollbackAsync().GetAwaiter().GetResult();
47126

127+
/// <summary>
128+
/// Asynchronously rolls back the database transaction.
129+
/// </summary>
130+
/// <param name="cancellationToken">A token to cancel the operation.</param>
131+
/// <returns>A task representing the asynchronous operation.</returns>
132+
/// <exception cref="InvalidOperationException">
133+
/// Thrown when the transaction has already been completed or the connection is closed.
134+
/// </exception>
135+
/// <exception cref="YdbOperationInProgressException">
136+
/// Thrown when another operation is in progress on the connection.
137+
/// </exception>
138+
/// <exception cref="YdbException">
139+
/// Thrown when the rollback operation fails.
140+
/// </exception>
48141
public override async Task RollbackAsync(CancellationToken cancellationToken = new())
49142
{
50143
if (Failed)
@@ -57,6 +150,13 @@ internal YdbTransaction(YdbConnection ydbConnection, TransactionMode transaction
57150
await FinishTransaction(txId => DbConnection!.Session.RollbackTransaction(txId, cancellationToken));
58151
}
59152

153+
/// <summary>
154+
/// Gets the database connection associated with this transaction.
155+
/// </summary>
156+
/// <returns>The YdbConnection associated with this transaction, or null if disposed.</returns>
157+
/// <exception cref="ObjectDisposedException">
158+
/// Thrown when the transaction has been disposed.
159+
/// </exception>
60160
protected override YdbConnection? DbConnection
61161
{
62162
get
@@ -66,6 +166,13 @@ protected override YdbConnection? DbConnection
66166
}
67167
}
68168

169+
/// <summary>
170+
/// Gets the isolation level of this transaction.
171+
/// </summary>
172+
/// <remarks>
173+
/// Returns Serializable for SerializableRw transaction mode, otherwise Unspecified.
174+
/// The actual isolation level depends on the transaction mode used when creating the transaction.
175+
/// </remarks>
69176
public override IsolationLevel IsolationLevel => _transactionMode == TransactionMode.SerializableRw
70177
? IsolationLevel.Serializable
71178
: IsolationLevel.Unspecified;
@@ -107,6 +214,13 @@ private async Task FinishTransaction(Func<string, Task> finishMethod)
107214
}
108215
}
109216

217+
/// <summary>
218+
/// Releases the unmanaged resources used by the YdbTransaction and optionally releases the managed resources.
219+
/// </summary>
220+
/// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
221+
/// <remarks>
222+
/// If the transaction is not completed, it will be rolled back before disposal.
223+
/// </remarks>
110224
protected override void Dispose(bool disposing)
111225
{
112226
if (_isDisposed || !disposing)
@@ -120,6 +234,13 @@ protected override void Dispose(bool disposing)
120234
_isDisposed = true;
121235
}
122236

237+
/// <summary>
238+
/// Asynchronously releases the unmanaged resources used by the YdbTransaction.
239+
/// </summary>
240+
/// <returns>A ValueTask representing the asynchronous disposal operation.</returns>
241+
/// <remarks>
242+
/// If the transaction is not completed, it will be rolled back before disposal.
243+
/// </remarks>
123244
public override async ValueTask DisposeAsync()
124245
{
125246
if (_isDisposed)

0 commit comments

Comments
 (0)