Skip to content

Commit

Permalink
#941 Supported the 'traceKey' and 'trace' to both the BaseRepository …
Browse files Browse the repository at this point in the history
…and DbRepository operations.
  • Loading branch information
mikependon committed Sep 12, 2022
1 parent 33051dd commit 3dfeffd
Show file tree
Hide file tree
Showing 74 changed files with 9,439 additions and 3,258 deletions.
138 changes: 69 additions & 69 deletions RepoDb.Core/RepoDb/Extensions/DbConnectionExtension.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion RepoDb.Core/RepoDb/Interfaces/ITrace.cs
Expand Up @@ -24,7 +24,7 @@ public interface ITrace
/// </summary>
/// <typeparam name="TResult">The type of the result.</typeparam>
/// <param name="log">The trace log object referenced by the execution.</param>
void AfterExcecution<TResult>(ResultTraceLog<TResult> log);
void AfterExecution<TResult>(ResultTraceLog<TResult> log);

#endregion

Expand Down
360 changes: 240 additions & 120 deletions RepoDb.Core/RepoDb/Operations/BaseRepository/Average.cs

Large diffs are not rendered by default.

72 changes: 48 additions & 24 deletions RepoDb.Core/RepoDb/Operations/BaseRepository/AverageAll.cs
Expand Up @@ -15,31 +15,37 @@ public abstract partial class BaseRepository<TEntity, TDbConnection> : IDisposab
/// </averagemary>
/// <param name="field">The field to be averaged.</param>
/// <param name="hints">The table hints to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <param name="traceKey">The tracing key to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <returns>The average value of the target field.</returns>
public object AverageAll(Field field,
string hints = null,
IDbTransaction transaction = null)
string traceKey = TraceKeys.AverageAll,
IDbTransaction transaction = null)
{
return DbRepository.AverageAll<TEntity>(field: field,
hints: hints,
transaction: transaction);
traceKey: traceKey,
transaction: transaction);
}

/// <averagemary>
/// Computes the average value of the target field.
/// </averagemary>
/// <param name="field">The field to be averaged.</param>
/// <param name="hints">The table hints to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <param name="traceKey">The tracing key to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <returns>The average value of the target field.</returns>
public object AverageAll(Expression<Func<TEntity, object>> field,
string hints = null,
IDbTransaction transaction = null)
string traceKey = TraceKeys.AverageAll,
IDbTransaction transaction = null)
{
return DbRepository.AverageAll<TEntity>(field: field,
hints: hints,
transaction: transaction);
traceKey: traceKey,
transaction: transaction);
}

/// <averagemary>
Expand All @@ -48,15 +54,18 @@ public abstract partial class BaseRepository<TEntity, TDbConnection> : IDisposab
/// <typeparam name="TResult">The type of the result.</typeparam>
/// <param name="field">The field to be averaged.</param>
/// <param name="hints">The table hints to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <param name="traceKey">The tracing key to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <returns>The average value of the target field.</returns>
public TResult AverageAll<TResult>(Field field,
string hints = null,
IDbTransaction transaction = null)
string traceKey = TraceKeys.AverageAll,
IDbTransaction transaction = null)
{
return DbRepository.AverageAll<TEntity, TResult>(field: field,
hints: hints,
transaction: transaction);
traceKey: traceKey,
transaction: transaction);
}

/// <averagemary>
Expand All @@ -65,15 +74,18 @@ public abstract partial class BaseRepository<TEntity, TDbConnection> : IDisposab
/// <typeparam name="TResult">The type of the result.</typeparam>
/// <param name="field">The field to be averaged.</param>
/// <param name="hints">The table hints to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <param name="traceKey">The tracing key to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <returns>The average value of the target field.</returns>
public TResult AverageAll<TResult>(Expression<Func<TEntity, TResult>> field,
string hints = null,
IDbTransaction transaction = null)
string traceKey = TraceKeys.AverageAll,
IDbTransaction transaction = null)
{
return DbRepository.AverageAll<TEntity, TResult>(field: field,
hints: hints,
transaction: transaction);
traceKey: traceKey,
transaction: transaction);
}

#endregion
Expand All @@ -85,17 +97,20 @@ public abstract partial class BaseRepository<TEntity, TDbConnection> : IDisposab
/// </averagemary>
/// <param name="field">The field to be averaged.</param>
/// <param name="hints">The table hints to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <param name="traceKey">The tracing key to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> object to be used during the asynchronous operation.</param>
/// <returns>The average value of the target field.</returns>
public Task<object> AverageAllAsync(Field field,
string hints = null,
IDbTransaction transaction = null,
string traceKey = TraceKeys.AverageAll,
IDbTransaction transaction = null,
CancellationToken cancellationToken = default)
{
return DbRepository.AverageAllAsync<TEntity>(field: field,
hints: hints,
transaction: transaction,
traceKey: traceKey,
transaction: transaction,
cancellationToken: cancellationToken);
}

Expand All @@ -104,17 +119,20 @@ public abstract partial class BaseRepository<TEntity, TDbConnection> : IDisposab
/// </averagemary>
/// <param name="field">The field to be averaged.</param>
/// <param name="hints">The table hints to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <param name="traceKey">The tracing key to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> object to be used during the asynchronous operation.</param>
/// <returns>The average value of the target field.</returns>
public Task<object> AverageAllAsync(Expression<Func<TEntity, object>> field,
string hints = null,
IDbTransaction transaction = null,
string traceKey = TraceKeys.AverageAll,
IDbTransaction transaction = null,
CancellationToken cancellationToken = default)
{
return DbRepository.AverageAllAsync<TEntity>(field: field,
hints: hints,
transaction: transaction,
traceKey: traceKey,
transaction: transaction,
cancellationToken: cancellationToken);
}

Expand All @@ -124,17 +142,20 @@ public abstract partial class BaseRepository<TEntity, TDbConnection> : IDisposab
/// <typeparam name="TResult">The type of the result.</typeparam>
/// <param name="field">The field to be averaged.</param>
/// <param name="hints">The table hints to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <param name="traceKey">The tracing key to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> object to be used during the asynchronous operation.</param>
/// <returns>The average value of the target field.</returns>
public Task<TResult> AverageAllAsync<TResult>(Field field,
string hints = null,
IDbTransaction transaction = null,
string traceKey = TraceKeys.AverageAll,
IDbTransaction transaction = null,
CancellationToken cancellationToken = default)
{
return DbRepository.AverageAllAsync<TEntity, TResult>(field: field,
hints: hints,
transaction: transaction,
traceKey: traceKey,
transaction: transaction,
cancellationToken: cancellationToken);
}

Expand All @@ -144,17 +165,20 @@ public abstract partial class BaseRepository<TEntity, TDbConnection> : IDisposab
/// <typeparam name="TResult">The type of the result.</typeparam>
/// <param name="field">The field to be averaged.</param>
/// <param name="hints">The table hints to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <param name="traceKey">The tracing key to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> object to be used during the asynchronous operation.</param>
/// <returns>The average value of the target field.</returns>
public Task<TResult> AverageAllAsync<TResult>(Expression<Func<TEntity, TResult>> field,
string hints = null,
IDbTransaction transaction = null,
string traceKey = TraceKeys.AverageAll,
IDbTransaction transaction = null,
CancellationToken cancellationToken = default)
{
return DbRepository.AverageAllAsync<TEntity, TResult>(field: field,
hints: hints,
transaction: transaction,
traceKey: traceKey,
transaction: transaction,
cancellationToken: cancellationToken);
}

Expand Down

0 comments on commit 3dfeffd

Please sign in to comment.