feat(IQueryExecutor): IQuery umbenennen
This commit is contained in:
@@ -4,11 +4,11 @@ using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EnvelopeGenerator.Infrastructure;
|
||||
|
||||
public sealed record QueryExecutor<TEntity> : IQueryExecutor<TEntity>
|
||||
public sealed record Query<TEntity> : IQuery<TEntity>
|
||||
{
|
||||
private readonly IQueryable<TEntity> _query;
|
||||
|
||||
internal QueryExecutor(IQueryable<TEntity> queryable)
|
||||
internal Query(IQueryable<TEntity> queryable)
|
||||
{
|
||||
_query = queryable;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace EnvelopeGenerator.Infrastructure;
|
||||
|
||||
public static class QueryExecutorExtension
|
||||
{
|
||||
public static QueryExecutor<TEntity> ToExecutor<TEntity>(this IQueryable<TEntity> queryable) where TEntity : class
|
||||
{
|
||||
return new QueryExecutor<TEntity>(queryable);
|
||||
}
|
||||
}
|
||||
9
EnvelopeGenerator.Infrastructure/QueryExtension.cs
Normal file
9
EnvelopeGenerator.Infrastructure/QueryExtension.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace EnvelopeGenerator.Infrastructure;
|
||||
|
||||
public static class QueryExtension
|
||||
{
|
||||
public static Query<TEntity> ToQuery<TEntity>(this IQueryable<TEntity> queryable) where TEntity : class
|
||||
{
|
||||
return new Query<TEntity>(queryable);
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,13 @@ public sealed class SQLExecutor<T> : ISQLExecutor<T> where T : class
|
||||
_provider = provider;
|
||||
}
|
||||
|
||||
public IQueryExecutor<T> Execute(string sql, CancellationToken cancellation = default, params object[] parameters)
|
||||
public IQuery<T> Execute(string sql, CancellationToken cancellation = default, params object[] parameters)
|
||||
=> _context
|
||||
.Set<T>()
|
||||
.FromSqlRaw(sql, parameters)
|
||||
.ToExecutor();
|
||||
.ToQuery();
|
||||
|
||||
public IQueryExecutor<T> Execute<TSQL>(CancellationToken cancellation = default, params object[] parameters) where TSQL : ISQL<T>
|
||||
public IQuery<T> Execute<TSQL>(CancellationToken cancellation = default, params object[] parameters) where TSQL : ISQL<T>
|
||||
{
|
||||
var sql = _provider.GetRequiredService<TSQL>();
|
||||
return Execute(sql.Raw);
|
||||
|
||||
Reference in New Issue
Block a user