Skip to content

Commit aab0d86

Browse files
author
jaguzman
committed
Removed executesql function that used conventions
1 parent ed75def commit aab0d86

File tree

22 files changed

+346
-1243
lines changed

22 files changed

+346
-1243
lines changed

src/DotNetToolkit.Repository.AdoNet/DbHelper.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,15 @@ public T ExecuteScalar<T>(string cmdText, Dictionary<string, object> parameters
388388
/// <param name="parameters">The command parameters.</param>
389389
/// <param name="projector">A function to project each entity into a new form.</param>
390390
/// <returns>An entity which has been projected into a new form.</returns>
391-
public T ExecuteObject<T>(string cmdText, CommandType cmdType, Dictionary<string, object> parameters, Func<DbDataReader, IRepositoryConventions, T> projector)
391+
public T ExecuteObject<T>(string cmdText, CommandType cmdType, Dictionary<string, object> parameters, Func<DbDataReader, T> projector)
392392
{
393393
using (var reader = ExecuteReader(cmdText, cmdType, parameters))
394394
{
395395
var list = new List<T>();
396396

397397
while (reader.Read())
398398
{
399-
list.Add(projector(reader, _conventions));
399+
list.Add(projector(reader));
400400
}
401401

402402
var result = list.FirstOrDefault();
@@ -413,7 +413,7 @@ public T ExecuteObject<T>(string cmdText, CommandType cmdType, Dictionary<string
413413
/// <param name="parameters">The command parameters.</param>
414414
/// <param name="projector">A function to project each entity into a new form.</param>
415415
/// <returns>An entity which has been projected into a new form.</returns>
416-
public T ExecuteObject<T>(string cmdText, Dictionary<string, object> parameters, Func<DbDataReader, IRepositoryConventions, T> projector)
416+
public T ExecuteObject<T>(string cmdText, Dictionary<string, object> parameters, Func<DbDataReader, T> projector)
417417
{
418418
return ExecuteObject<T>(cmdText, CommandType.Text, parameters, projector);
419419
}
@@ -427,7 +427,7 @@ public T ExecuteObject<T>(string cmdText, Dictionary<string, object> parameters,
427427
/// <param name="parameters">The command parameters.</param>
428428
/// <param name="projector">A function to project each entity into a new form.</param>
429429
/// <returns>A list which each entity has been projected into a new form.</returns>
430-
internal IPagedQueryResult<IEnumerable<T>> ExecuteList<T>(string cmdText, CommandType cmdType, Dictionary<string, object> parameters, Func<DbDataReader, IRepositoryConventions, T> projector)
430+
internal IPagedQueryResult<IEnumerable<T>> ExecuteList<T>(string cmdText, CommandType cmdType, Dictionary<string, object> parameters, Func<DbDataReader, T> projector)
431431
{
432432
using (var reader = ExecuteReader(cmdText, cmdType, parameters))
433433
{
@@ -451,7 +451,7 @@ internal IPagedQueryResult<IEnumerable<T>> ExecuteList<T>(string cmdText, Comman
451451
}
452452
}
453453

454-
list.Add(projector(reader, _conventions));
454+
list.Add(projector(reader));
455455
}
456456

457457
if (!foundCrossJoinCountColumn)
@@ -469,7 +469,7 @@ internal IPagedQueryResult<IEnumerable<T>> ExecuteList<T>(string cmdText, Comman
469469
/// <param name="parameters">The command parameters.</param>
470470
/// <param name="projector">A function to project each entity into a new form.</param>
471471
/// <returns>A list which each entity has been projected into a new form.</returns>
472-
internal IPagedQueryResult<IEnumerable<T>> ExecuteList<T>(string cmdText, Dictionary<string, object> parameters, Func<DbDataReader, IRepositoryConventions, T> projector)
472+
internal IPagedQueryResult<IEnumerable<T>> ExecuteList<T>(string cmdText, Dictionary<string, object> parameters, Func<DbDataReader, T> projector)
473473
{
474474
return ExecuteList<T>(cmdText, CommandType.Text, parameters, projector);
475475
}
@@ -485,7 +485,7 @@ internal IPagedQueryResult<IEnumerable<T>> ExecuteList<T>(string cmdText, Dictio
485485
{
486486
var mapper = new Mapper<T>(_conventions);
487487

488-
return ExecuteList<T>(cmdText, parameters, (r, c) => mapper.Map(r));
488+
return ExecuteList<T>(cmdText, parameters, mapper.Map);
489489
}
490490

491491
/// <summary>
@@ -496,7 +496,7 @@ internal IPagedQueryResult<IEnumerable<T>> ExecuteList<T>(string cmdText, Dictio
496496
/// <param name="cmdType">The command type.</param>
497497
/// <param name="projector">A function to project each entity into a new form.</param>
498498
/// <returns>A list which each entity has been projected into a new form.</returns>
499-
internal IPagedQueryResult<IEnumerable<T>> ExecuteList<T>(string cmdText, CommandType cmdType, Func<DbDataReader, IRepositoryConventions, T> projector)
499+
internal IPagedQueryResult<IEnumerable<T>> ExecuteList<T>(string cmdText, CommandType cmdType, Func<DbDataReader, T> projector)
500500
{
501501
return ExecuteList<T>(cmdText, cmdType, null, projector);
502502
}
@@ -918,15 +918,15 @@ public DataSet ExecuteDataSet(string cmdText, Dictionary<string, object> paramet
918918
/// <param name="projector">A function to project each entity into a new form.</param>
919919
/// <param name="cancellationToken">A <see cref="System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
920920
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing an entity which has been projected into a new form.</returns>
921-
public async Task<T> ExecuteObjectAsync<T>(string cmdText, CommandType cmdType, Dictionary<string, object> parameters, Func<DbDataReader, IRepositoryConventions, T> projector, CancellationToken cancellationToken = new CancellationToken())
921+
public async Task<T> ExecuteObjectAsync<T>(string cmdText, CommandType cmdType, Dictionary<string, object> parameters, Func<DbDataReader, T> projector, CancellationToken cancellationToken = new CancellationToken())
922922
{
923923
using (var reader = await ExecuteReaderAsync(cmdText, cmdType, parameters, cancellationToken))
924924
{
925925
var list = new List<T>();
926926

927927
while (reader.Read())
928928
{
929-
list.Add(projector(reader, _conventions));
929+
list.Add(projector(reader));
930930
}
931931

932932
var result = list.FirstOrDefault();
@@ -944,7 +944,7 @@ public DataSet ExecuteDataSet(string cmdText, Dictionary<string, object> paramet
944944
/// <param name="projector">A function to project each entity into a new form.</param>
945945
/// <param name="cancellationToken">A <see cref="System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
946946
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing an entity which has been projected into a new form.</returns>
947-
public Task<T> ExecuteObjectAsync<T>(string cmdText, Dictionary<string, object> parameters, Func<DbDataReader, IRepositoryConventions, T> projector, CancellationToken cancellationToken = new CancellationToken())
947+
public Task<T> ExecuteObjectAsync<T>(string cmdText, Dictionary<string, object> parameters, Func<DbDataReader, T> projector, CancellationToken cancellationToken = new CancellationToken())
948948
{
949949
return ExecuteObjectAsync<T>(cmdText, CommandType.Text, parameters, projector, cancellationToken);
950950
}
@@ -959,7 +959,7 @@ public DataSet ExecuteDataSet(string cmdText, Dictionary<string, object> paramet
959959
/// <param name="projector">A function to project each entity into a new form.</param>
960960
/// <param name="cancellationToken">A <see cref="System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
961961
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing a list which each entity has been projected into a new form.</returns>
962-
internal async Task<IPagedQueryResult<IEnumerable<T>>> ExecuteListAsync<T>(string cmdText, CommandType cmdType, Dictionary<string, object> parameters, Func<DbDataReader, IRepositoryConventions, T> projector, CancellationToken cancellationToken = new CancellationToken())
962+
internal async Task<IPagedQueryResult<IEnumerable<T>>> ExecuteListAsync<T>(string cmdText, CommandType cmdType, Dictionary<string, object> parameters, Func<DbDataReader, T> projector, CancellationToken cancellationToken = new CancellationToken())
963963
{
964964
using (var reader = await ExecuteReaderAsync(cmdText, cmdType, parameters, cancellationToken))
965965
{
@@ -983,7 +983,7 @@ public DataSet ExecuteDataSet(string cmdText, Dictionary<string, object> paramet
983983
}
984984
}
985985

986-
list.Add(projector(reader, _conventions));
986+
list.Add(projector(reader));
987987
}
988988

989989
if (!foundCrossJoinCountColumn)
@@ -1002,7 +1002,7 @@ public DataSet ExecuteDataSet(string cmdText, Dictionary<string, object> paramet
10021002
/// <param name="projector">A function to project each entity into a new form.</param>
10031003
/// <param name="cancellationToken">A <see cref="System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
10041004
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing a list which each entity has been projected into a new form.</returns>
1005-
internal Task<IPagedQueryResult<IEnumerable<T>>> ExecuteListAsync<T>(string cmdText, Dictionary<string, object> parameters, Func<DbDataReader, IRepositoryConventions, T> projector, CancellationToken cancellationToken = new CancellationToken())
1005+
internal Task<IPagedQueryResult<IEnumerable<T>>> ExecuteListAsync<T>(string cmdText, Dictionary<string, object> parameters, Func<DbDataReader, T> projector, CancellationToken cancellationToken = new CancellationToken())
10061006
{
10071007
return ExecuteListAsync<T>(cmdText, CommandType.Text, parameters, projector, cancellationToken);
10081008
}
@@ -1019,7 +1019,7 @@ public DataSet ExecuteDataSet(string cmdText, Dictionary<string, object> paramet
10191019
{
10201020
var mapper = new Mapper<T>(_conventions);
10211021

1022-
return ExecuteListAsync<T>(cmdText, parameters, (r, c) => mapper.Map(r), cancellationToken);
1022+
return ExecuteListAsync<T>(cmdText, parameters, mapper.Map, cancellationToken);
10231023
}
10241024

10251025
/// <summary>

src/DotNetToolkit.Repository.AdoNet/Internal/AdoNetRepositoryContext.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ private async Task ExecuteSchemaValidateAsync(Type entityType, CancellationToken
218218
/// <param name="parameters">The parameters to apply to the SQL query string.</param>
219219
/// <param name="projector">A function to project each entity into a new form.</param>
220220
/// <returns>A list which each entity has been projected into a new form.</returns>
221-
public IEnumerable<TEntity> ExecuteSqlQuery<TEntity>(string sql, CommandType cmdType, Dictionary<string, object> parameters, Func<IDataReader, IRepositoryConventions, TEntity> projector) where TEntity : class
221+
public IEnumerable<TEntity> ExecuteSqlQuery<TEntity>(string sql, CommandType cmdType, Dictionary<string, object> parameters, Func<IDataReader, TEntity> projector) where TEntity : class
222222
{
223223
Guard.NotEmpty(sql, nameof(sql));
224224
Guard.NotNull(projector, nameof(projector));
@@ -229,7 +229,7 @@ public IEnumerable<TEntity> ExecuteSqlQuery<TEntity>(string sql, CommandType cmd
229229

230230
while (reader.Read())
231231
{
232-
list.Add(projector(reader, Conventions));
232+
list.Add(projector(reader));
233233
}
234234

235235
return list;
@@ -402,7 +402,7 @@ public TEntity Find<TEntity>(IFetchQueryStrategy<TEntity> fetchStrategy, params
402402

403403
ExecuteSchemaValidate(typeof(TEntity));
404404

405-
return _dbHelper.ExecuteObject<TEntity>(sql, parameters, (r, c) => mapper.Map<TEntity>(r, selectorFunc));
405+
return _dbHelper.ExecuteObject<TEntity>(sql, parameters, r => mapper.Map<TEntity>(r, selectorFunc));
406406
}
407407

408408
/// <summary>
@@ -431,7 +431,7 @@ public TResult Find<TEntity, TResult>(IQueryOptions<TEntity> options, Expression
431431

432432
ExecuteSchemaValidate(typeof(TEntity));
433433

434-
return _dbHelper.ExecuteObject<TResult>(sql, parameters, (r, c) => mapper.Map<TResult>(r, selectorFunc));
434+
return _dbHelper.ExecuteObject<TResult>(sql, parameters, r => mapper.Map<TResult>(r, selectorFunc));
435435
}
436436

437437
/// <summary>
@@ -460,7 +460,7 @@ public IPagedQueryResult<IEnumerable<TResult>> FindAll<TEntity, TResult>(IQueryO
460460

461461
ExecuteSchemaValidate(typeof(TEntity));
462462

463-
return _dbHelper.ExecuteList<TResult>(sql, parameters, (r, c) => mapper.Map<TResult>(r, selectorFunc));
463+
return _dbHelper.ExecuteList<TResult>(sql, parameters, r => mapper.Map<TResult>(r, selectorFunc));
464464
}
465465

466466
/// <summary>
@@ -609,7 +609,7 @@ public IPagedQueryResult<IEnumerable<TResult>> GroupBy<TEntity, TGroupKey, TResu
609609
/// <param name="projector">A function to project each entity into a new form.</param>
610610
/// <param name="cancellationToken">A <see cref="System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
611611
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing a list which each entity has been projected into a new form.</returns>
612-
public async Task<IEnumerable<TEntity>> ExecuteSqlQueryAsync<TEntity>(string sql, CommandType cmdType, Dictionary<string, object> parameters, Func<IDataReader, IRepositoryConventions, TEntity> projector, CancellationToken cancellationToken = new CancellationToken()) where TEntity : class
612+
public async Task<IEnumerable<TEntity>> ExecuteSqlQueryAsync<TEntity>(string sql, CommandType cmdType, Dictionary<string, object> parameters, Func<IDataReader, TEntity> projector, CancellationToken cancellationToken = new CancellationToken()) where TEntity : class
613613
{
614614
Guard.NotEmpty(sql, nameof(sql));
615615
Guard.NotNull(projector, nameof(projector));
@@ -620,7 +620,7 @@ public IPagedQueryResult<IEnumerable<TResult>> GroupBy<TEntity, TGroupKey, TResu
620620

621621
while (await reader.ReadAsync(cancellationToken))
622622
{
623-
list.Add(projector(reader, Conventions));
623+
list.Add(projector(reader));
624624
}
625625

626626
return list;
@@ -747,7 +747,7 @@ public async Task<TEntity> FindAsync<TEntity>(CancellationToken cancellationToke
747747

748748
await ExecuteSchemaValidateAsync(typeof(TEntity), cancellationToken);
749749

750-
return await _dbHelper.ExecuteObjectAsync<TEntity>(sql, parameters, (r, c) => mapper.Map<TEntity>(r, selectorFunc), cancellationToken);
750+
return await _dbHelper.ExecuteObjectAsync<TEntity>(sql, parameters, r => mapper.Map<TEntity>(r, selectorFunc), cancellationToken);
751751
}
752752

753753
/// <summary>
@@ -777,7 +777,7 @@ public async Task<TEntity> FindAsync<TEntity>(CancellationToken cancellationToke
777777

778778
await ExecuteSchemaValidateAsync(typeof(TEntity), cancellationToken);
779779

780-
return await _dbHelper.ExecuteObjectAsync<TResult>(sql, parameters, (r, c) => mapper.Map<TResult>(r, selectorFunc), cancellationToken);
780+
return await _dbHelper.ExecuteObjectAsync<TResult>(sql, parameters, r => mapper.Map<TResult>(r, selectorFunc), cancellationToken);
781781
}
782782

783783
/// <summary>
@@ -807,7 +807,7 @@ public async Task<TEntity> FindAsync<TEntity>(CancellationToken cancellationToke
807807

808808
await ExecuteSchemaValidateAsync(typeof(TEntity), cancellationToken);
809809

810-
return await _dbHelper.ExecuteListAsync<TResult>(sql, parameters, (r, c) => mapper.Map<TResult>(r, selectorFunc), cancellationToken);
810+
return await _dbHelper.ExecuteListAsync<TResult>(sql, parameters, r => mapper.Map<TResult>(r, selectorFunc), cancellationToken);
811811
}
812812

813813
/// <summary>

src/DotNetToolkit.Repository.EntityFramework/Internal/EfRepositoryContext.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ protected override IQueryable<TEntity> ApplyFetchingOptions<TEntity>(IQueryable<
8282
/// <param name="parameters">The parameters to apply to the SQL query string.</param>
8383
/// <param name="projector">A function to project each entity into a new form.</param>
8484
/// <returns>A list which each entity has been projected into a new form.</returns>
85-
public override IEnumerable<TEntity> ExecuteSqlQuery<TEntity>(string sql, CommandType cmdType, Dictionary<string, object> parameters, Func<IDataReader, IRepositoryConventions, TEntity> projector)
85+
public override IEnumerable<TEntity> ExecuteSqlQuery<TEntity>(string sql, CommandType cmdType, Dictionary<string, object> parameters, Func<IDataReader, TEntity> projector)
8686
{
8787
Guard.NotEmpty(sql, nameof(sql));
8888
Guard.NotNull(projector, nameof(projector));
@@ -105,7 +105,7 @@ public override IEnumerable<TEntity> ExecuteSqlQuery<TEntity>(string sql, Comman
105105

106106
while (reader.Read())
107107
{
108-
list.Add(projector(reader, Conventions));
108+
list.Add(projector(reader));
109109
}
110110

111111
return list;
@@ -309,7 +309,7 @@ protected override Task<Dictionary<TKey, TElement>> ToDictionaryAsync<TSource, T
309309
/// <param name="projector">A function to project each entity into a new form.</param>
310310
/// <param name="cancellationToken">A <see cref="System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
311311
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing a list which each entity has been projected into a new form.</returns>
312-
public override async Task<IEnumerable<TEntity>> ExecuteSqlQueryAsync<TEntity>(string sql, CommandType cmdType, Dictionary<string, object> parameters, Func<IDataReader, IRepositoryConventions, TEntity> projector, CancellationToken cancellationToken = new CancellationToken())
312+
public override async Task<IEnumerable<TEntity>> ExecuteSqlQueryAsync<TEntity>(string sql, CommandType cmdType, Dictionary<string, object> parameters, Func<IDataReader, TEntity> projector, CancellationToken cancellationToken = new CancellationToken())
313313
{
314314
Guard.NotEmpty(sql, nameof(sql));
315315
Guard.NotNull(projector, nameof(projector));
@@ -332,7 +332,7 @@ protected override Task<Dictionary<TKey, TElement>> ToDictionaryAsync<TSource, T
332332

333333
while (await reader.ReadAsync(cancellationToken))
334334
{
335-
list.Add(projector(reader, Conventions));
335+
list.Add(projector(reader));
336336
}
337337

338338
return list;

0 commit comments

Comments
 (0)