Skip to content

Commit 5ad3707

Browse files
author
Oren (electricessence)
committed
Reformat
1 parent e29b34a commit 5ad3707

18 files changed

Lines changed: 4011 additions & 620 deletions

DbConnectionFactory.cs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,44 @@
55

66
namespace Open.Database.Extensions
77
{
8-
/// <summary>
9-
/// Generic connection factory implementation that accepts a factory function.
10-
/// </summary>
11-
/// <typeparam name="TConnection"></typeparam>
12-
public class DbConnectionFactory<TConnection> : IDbConnectionFactory<TConnection>
13-
where TConnection:DbConnection
14-
{
15-
readonly Func<TConnection> _factory;
8+
/// <summary>
9+
/// Generic connection factory implementation that accepts a factory function.
10+
/// </summary>
11+
/// <typeparam name="TConnection"></typeparam>
12+
public class DbConnectionFactory<TConnection> : IDbConnectionFactory<TConnection>
13+
where TConnection : DbConnection
14+
{
15+
readonly Func<TConnection> _factory;
1616

17-
/// <summary>
18-
/// Constructs a DbConnectionFactory.
19-
/// </summary>
20-
/// <param name="factory"></param>
21-
public DbConnectionFactory(Func<TConnection> factory)
22-
{
23-
_factory = factory ?? throw new ArgumentNullException(nameof(factory));
24-
Contract.EndContractBlock();
25-
}
17+
/// <summary>
18+
/// Constructs a DbConnectionFactory.
19+
/// </summary>
20+
/// <param name="factory"></param>
21+
public DbConnectionFactory(Func<TConnection> factory)
22+
{
23+
_factory = factory ?? throw new ArgumentNullException(nameof(factory));
24+
Contract.EndContractBlock();
25+
}
2626

27-
/// <summary>
28-
/// Creates a connection of from the underlying factory function.
29-
/// </summary>
30-
public virtual TConnection Create() => _factory();
27+
/// <summary>
28+
/// Creates a connection of from the underlying factory function.
29+
/// </summary>
30+
public virtual TConnection Create() => _factory();
3131

32-
IDbConnection IDbConnectionFactory.Create() => Create();
33-
}
32+
IDbConnection IDbConnectionFactory.Create() => Create();
33+
}
3434

35-
/// <summary>
36-
/// DbConnection factory implementation that accepts a factory function.
37-
/// </summary>
38-
public class DbConnectionFactory : DbConnectionFactory<DbConnection>
39-
{
40-
/// <summary>
41-
/// Constructs a DbConnectionFactory.
42-
/// </summary>
43-
/// <param name="factory"></param>
44-
public DbConnectionFactory(Func<DbConnection> factory) : base(factory)
45-
{
46-
}
47-
}
35+
/// <summary>
36+
/// DbConnection factory implementation that accepts a factory function.
37+
/// </summary>
38+
public class DbConnectionFactory : DbConnectionFactory<DbConnection>
39+
{
40+
/// <summary>
41+
/// Constructs a DbConnectionFactory.
42+
/// </summary>
43+
/// <param name="factory"></param>
44+
public DbConnectionFactory(Func<DbConnection> factory) : base(factory)
45+
{
46+
}
47+
}
4848
}

Documentation.xml

Lines changed: 3391 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ExpressiveCommandBase.Param.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
namespace Open.Database.Extensions
55
{
66

7-
public abstract partial class ExpressiveCommandBase<TConnection, TCommand, TDbType, TThis>
7+
public abstract partial class ExpressiveCommandBase<TConnection, TCommand, TDbType, TThis>
88
where TConnection : class, IDbConnection
9-
where TCommand : class, IDbCommand
10-
where TDbType : struct
9+
where TCommand : class, IDbCommand
10+
where TDbType : struct
1111
where TThis : ExpressiveCommandBase<TConnection, TCommand, TDbType, TThis>
1212
{
1313
#pragma warning disable CS0659 // Type overrides Object.Equals(object o) but does not override Object.GetHashCode()
@@ -49,7 +49,7 @@ public override bool Equals(object obj) => obj is Param o
4949
/// Equality operator.
5050
/// </summary>
5151
public static bool operator ==(Param left, Param right) => left.Equals(right);
52-
52+
5353
/// <summary>
5454
/// Inequality operator.
5555
/// </summary>

ExpressiveDbCommand.cs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ namespace Open.Database.Extensions
99
/// An abstraction for executing commands on a database using best practices and simplified expressive syntax.
1010
/// </summary>
1111
public class ExpressiveDbCommand : ExpressiveDbCommandBase<DbConnection, DbCommand, DbType, ExpressiveDbCommand>
12-
{
13-
/// <param name="connFactory">The factory to generate connections from.</param>
14-
/// <param name="type">The command type>.</param>
15-
/// <param name="command">The SQL command.</param>
16-
/// <param name="params">The list of params</param>
17-
public ExpressiveDbCommand(
12+
{
13+
/// <param name="connFactory">The factory to generate connections from.</param>
14+
/// <param name="type">The command type>.</param>
15+
/// <param name="command">The SQL command.</param>
16+
/// <param name="params">The list of params</param>
17+
public ExpressiveDbCommand(
1818
IDbConnectionFactory<DbConnection> connFactory,
1919
CommandType type,
2020
string command,
2121
IEnumerable<Param> @params = null)
22-
: base(connFactory, type, command, @params)
23-
{
24-
}
22+
: base(connFactory, type, command, @params)
23+
{
24+
}
2525

2626
/// <param name="connection">The connection to execute the command on.</param>
2727
/// <param name="transaction">The optional transaction to execute the command on.</param>
@@ -34,23 +34,23 @@ public ExpressiveDbCommand(
3434
CommandType type,
3535
string command,
3636
IEnumerable<Param> @params = null)
37-
: base(connection, transaction, type, command, @params)
38-
{
39-
}
37+
: base(connection, transaction, type, command, @params)
38+
{
39+
}
4040

41-
/// <summary>
42-
/// Handles adding the list of parameters to a new command.
43-
/// </summary>
44-
/// <param name="command"></param>
45-
protected override void AddParams(DbCommand command)
46-
{
47-
foreach (var p in Params)
48-
{
49-
var np = command.AddParameter(p.Name, p.Value);
50-
if (p.Type.HasValue) np.DbType = p.Type.Value;
51-
}
52-
}
41+
/// <summary>
42+
/// Handles adding the list of parameters to a new command.
43+
/// </summary>
44+
/// <param name="command"></param>
45+
protected override void AddParams(DbCommand command)
46+
{
47+
foreach (var p in Params)
48+
{
49+
var np = command.AddParameter(p.Name, p.Value);
50+
if (p.Type.HasValue) np.DbType = p.Type.Value;
51+
}
52+
}
5353

54-
}
54+
}
5555

5656
}

ExpressiveDbCommandBase.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public Task<T> ExecuteReaderAsync<T>(Func<DbDataReader, T> transform, CommandBeh
230230
/// <returns>The result of the transform.</returns>
231231
public Task<T> ExecuteReaderAsync<T>(Func<DbDataReader, Task<T>> transform, CommandBehavior behavior = CommandBehavior.Default)
232232
{
233-
if (Connection==null || Connection.State == ConnectionState.Closed) behavior = behavior | CommandBehavior.CloseConnection;
233+
if (Connection == null || Connection.State == ConnectionState.Closed) behavior = behavior | CommandBehavior.CloseConnection;
234234
return ExecuteAsync(async command => await transform(await command.ExecuteReaderAsync(behavior, CancellationToken).ConfigureAwait(false)));
235235
}
236236

@@ -398,7 +398,8 @@ public ISourceBlock<T> AsSourceBlockAsync<T>(Func<IDataRecord, T> transform)
398398

399399
var source = new BufferBlock<T>();
400400
ToTargetBlockAsync(source, transform)
401-
.ContinueWith(t => {
401+
.ContinueWith(t =>
402+
{
402403
if (t.IsFaulted) ((ITargetBlock<T>)source).Fault(t.Exception);
403404
else source.Complete();
404405
})

0 commit comments

Comments
 (0)