Skip to content

Commit 9961fa9

Browse files
committed
add support for registering multiple IDataSession
1 parent e2a3936 commit 9961fa9

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

src/FluentCommand/DataSession.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public DataSession(DbTransaction transaction, bool disposeConnection = false, ID
9494
/// <summary>
9595
/// Initializes a new instance of the <see cref="DataSession" /> class.
9696
/// </summary>
97+
/// <param name="dataConfiguration">The configuration for the session</param>
9798
/// <exception cref="ArgumentNullException"><paramref name="dataConfiguration"/> is null</exception>
9899
public DataSession(IDataConfiguration dataConfiguration)
99100
{
@@ -287,3 +288,52 @@ protected override void DisposeManagedResources()
287288
Connection.Dispose();
288289
}
289290
}
291+
292+
/// <summary>
293+
/// A fluent class for a data session by discriminator. Used to register multiple instances of IDataSession.
294+
/// </summary>
295+
/// <typeparam name="TDiscriminator">The type of the discriminator.</typeparam>
296+
/// <seealso cref="FluentCommand.DisposableBase" />
297+
/// <seealso cref="FluentCommand.IDataSession" />
298+
public class DataSession<TDiscriminator> : DataSession, IDataSession<TDiscriminator>
299+
{
300+
/// <summary>
301+
/// Initializes a new instance of the <see cref="DataSession" /> class.
302+
/// </summary>
303+
/// <param name="connection">The DbConnection to use for the session.</param>
304+
/// <param name="disposeConnection">if set to <c>true</c> dispose connection with this session.</param>
305+
/// <param name="cache">The <see cref="IDataCache" /> used to cached results of queries.</param>
306+
/// <param name="queryGenerator">The query generator provider.</param>
307+
/// <param name="logger">The logger delegate for writing log messages.</param>
308+
/// <exception cref="ArgumentNullException"><paramref name="connection" /> is null</exception>
309+
/// <exception cref="ArgumentException">Invalid connection string on <paramref name="connection" /> instance.</exception>
310+
public DataSession(DbConnection connection, bool disposeConnection = true, IDataCache cache = null, IQueryGenerator queryGenerator = null, IDataQueryLogger logger = null)
311+
: base(connection, disposeConnection, cache, queryGenerator, logger)
312+
{
313+
}
314+
315+
/// <summary>
316+
/// Initializes a new instance of the <see cref="DataSession"/> class.
317+
/// </summary>
318+
/// <param name="transaction">The DbTransaction to use for the session.</param>
319+
/// <param name="disposeConnection">if set to <c>true</c> dispose connection with this session.</param>
320+
/// <param name="cache">The <see cref="IDataCache" /> used to cached results of queries.</param>
321+
/// <param name="queryGenerator">The query generator provider.</param>
322+
/// <param name="logger">The logger delegate for writing log messages.</param>
323+
/// <exception cref="ArgumentNullException"><paramref name="transaction" /> is null</exception>
324+
/// <exception cref="ArgumentException">Invalid connection string on <paramref name="transaction" /> instance.</exception>
325+
public DataSession(DbTransaction transaction, bool disposeConnection = false, IDataCache cache = null, IQueryGenerator queryGenerator = null, IDataQueryLogger logger = null)
326+
: base(transaction, disposeConnection, cache, queryGenerator, logger)
327+
{
328+
}
329+
330+
/// <summary>
331+
/// Initializes a new instance of the <see cref="DataSession" /> class.
332+
/// </summary>
333+
/// <param name="dataConfiguration">The configuration for the session</param>
334+
/// <exception cref="ArgumentNullException"><paramref name="dataConfiguration" /> is null</exception>
335+
public DataSession(IDataConfiguration<TDiscriminator> dataConfiguration)
336+
: base(dataConfiguration)
337+
{
338+
}
339+
}

src/FluentCommand/IDataSession.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,12 @@ public interface IDataSession
106106
Task ReleaseConnectionAsync();
107107
#endif
108108
}
109+
110+
/// <summary>
111+
/// A fluent interface for a data session by discriminator. Used to register multiple instances of IDataSession.
112+
/// </summary>
113+
/// <typeparam name="TDiscriminator">The type of the discriminator.</typeparam>
114+
public interface IDataSession<TDiscriminator> : IDataSession
115+
{
116+
117+
}

0 commit comments

Comments
 (0)