Skip to content

Commit

Permalink
Dapper request key
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed Jan 25, 2025
1 parent 7ee36de commit 816d30b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
47 changes: 47 additions & 0 deletions src/Shiny.Mediator.DapperRequests/Contracts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
namespace Shiny.Mediator;


public record DapperRequest<TResult>(
FormattableString Sql,
int? CommandTimeout = null,
string? RequestKey = null
) : IRequest<TResult>, IRequestKey
{
public string GetKey()
{
if (this.RequestKey != null)
return this.RequestKey;

var key = typeof(TResult).FullName + "_" + Sql;
return key;
}
}
public record DapperQuery<TResult>(
FormattableString Sql,
int? CommandTimeout = null,
string? RequestKey = null
) : DapperRequest<IEnumerable<TResult>>(
Sql,
CommandTimeout,
RequestKey
);

public record DapperFirstQuery<TResult>(
FormattableString Sql,
int? CommandTimeout = null,
string? RequestKey = null
) : DapperRequest<TResult>(
Sql,
CommandTimeout,
RequestKey
);

public record DapperScalar(
FormattableString Sql,
int? CommandTimeout = null,
string? RequestKey = null
) : DapperRequest<object>(
Sql,
CommandTimeout,
RequestKey
);
5 changes: 0 additions & 5 deletions src/Shiny.Mediator.DapperRequests/IDapperQuery.cs

This file was deleted.

0 comments on commit 816d30b

Please sign in to comment.