Skip to content

Commit 98f6eaf

Browse files
Merge pull request #544 from johelvisguzman/issue543
Added a new variant to the get method which takes in a string based path collection to fetch
2 parents 6dc3eaf + 10badbc commit 98f6eaf

File tree

10 files changed

+1203
-59
lines changed

10 files changed

+1203
-59
lines changed

src/DotNetToolkit.Repository/IReadOnlyRepository.cs

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public interface IReadOnlyRepository<TEntity, in TKey1, in TKey2, in TKey3> wher
211211
/// <param name="key3">The value of the third part of the composite primary key used to match entities against.</param>
212212
/// <param name="paths">The dot-separated list of related objects to return in the query results.</param>
213213
/// <return>The entity found.</return>
214-
TEntity Find(TKey1 key1, TKey2 key2, TKey3 key3, string[] paths);
214+
TEntity Find(TKey1 key1, TKey2 key2, TKey3 key3, params string[] paths);
215215

216216
/// <summary>
217217
/// Finds an entity with the given composite primary key values in the repository.
@@ -221,7 +221,7 @@ public interface IReadOnlyRepository<TEntity, in TKey1, in TKey2, in TKey3> wher
221221
/// <param name="key3">The value of the third part of the composite primary key used to match entities against.</param>
222222
/// <param name="paths">A collection of lambda expressions representing the paths to include.</param>
223223
/// <return>The entity found.</return>
224-
TEntity Find(TKey1 key1, TKey2 key2, TKey3 key3, Expression<Func<TEntity, object>>[] paths);
224+
TEntity Find(TKey1 key1, TKey2 key2, TKey3 key3, params Expression<Func<TEntity, object>>[] paths);
225225

226226
/// <summary>
227227
/// Finds an entity with the given composite primary key values in the repository.
@@ -418,6 +418,16 @@ public interface IReadOnlyRepository<TEntity, in TKey1, in TKey2, in TKey3> wher
418418
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing the entity found.</returns>
419419
Task<TEntity> FindAsync(TKey1 key1, TKey2 key2, TKey3 key3, CancellationToken cancellationToken = new CancellationToken());
420420

421+
/// <summary>
422+
/// Asynchronously finds an entity with the given composite primary key values in the repository.
423+
/// </summary>
424+
/// <param name="key1">The value of the first part of the composite primary key used to match entities against.</param>
425+
/// <param name="key2">The value of the second part of the composite primary key used to match entities against.</param>
426+
/// <param name="key3">The value of the third part of the composite primary key used to match entities against.</param>
427+
/// <param name="paths">The dot-separated list of related objects to return in the query results.</param>
428+
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing the entity found.</returns>
429+
Task<TEntity> FindAsync(TKey1 key1, TKey2 key2, TKey3 key3, params string[] paths);
430+
421431
/// <summary>
422432
/// Asynchronously finds an entity with the given composite primary key values in the repository.
423433
/// </summary>
@@ -429,6 +439,16 @@ public interface IReadOnlyRepository<TEntity, in TKey1, in TKey2, in TKey3> wher
429439
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing the entity found.</returns>
430440
Task<TEntity> FindAsync(TKey1 key1, TKey2 key2, TKey3 key3, string[] paths, CancellationToken cancellationToken = new CancellationToken());
431441

442+
/// <summary>
443+
/// Asynchronously finds an entity with the given composite primary key values in the repository.
444+
/// </summary>
445+
/// <param name="key1">The value of the first part of the composite primary key used to match entities against.</param>
446+
/// <param name="key2">The value of the second part of the composite primary key used to match entities against.</param>
447+
/// <param name="key3">The value of the third part of the composite primary key used to match entities against.</param>
448+
/// <param name="paths">A collection of lambda expressions representing the paths to include.</param>
449+
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing the entity found.</returns>
450+
Task<TEntity> FindAsync(TKey1 key1, TKey2 key2, TKey3 key3, params Expression<Func<TEntity, object>>[] paths);
451+
432452
/// <summary>
433453
/// Asynchronously finds an entity with the given composite primary key values in the repository.
434454
/// </summary>
@@ -847,7 +867,7 @@ public interface IReadOnlyRepository<TEntity, in TKey1, in TKey2> where TEntity
847867
/// <param name="key2">The value of the second part of the composite primary key used to match entities against.</param>
848868
/// <param name="paths">The dot-separated list of related objects to return in the query results.</param>
849869
/// <return>The entity found.</return>
850-
TEntity Find(TKey1 key1, TKey2 key2, string[] paths);
870+
TEntity Find(TKey1 key1, TKey2 key2, params string[] paths);
851871

852872
/// <summary>
853873
/// Finds an entity with the given composite primary key values in the repository.
@@ -856,7 +876,7 @@ public interface IReadOnlyRepository<TEntity, in TKey1, in TKey2> where TEntity
856876
/// <param name="key2">The value of the second part of the composite primary key used to match entities against.</param>
857877
/// <param name="paths">A collection of lambda expressions representing the paths to include.</param>
858878
/// <return>The entity found.</return>
859-
TEntity Find(TKey1 key1, TKey2 key2, Expression<Func<TEntity, object>>[] paths);
879+
TEntity Find(TKey1 key1, TKey2 key2, params Expression<Func<TEntity, object>>[] paths);
860880

861881
/// <summary>
862882
/// Finds an entity with the given composite primary key values in the repository.
@@ -1050,6 +1070,15 @@ public interface IReadOnlyRepository<TEntity, in TKey1, in TKey2> where TEntity
10501070
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing the entity found.</returns>
10511071
Task<TEntity> FindAsync(TKey1 key1, TKey2 key2, CancellationToken cancellationToken = new CancellationToken());
10521072

1073+
/// <summary>
1074+
/// Asynchronously finds an entity with the given composite primary key values in the repository.
1075+
/// </summary>
1076+
/// <param name="key1">The value of the first part of the composite primary key used to match entities against.</param>
1077+
/// <param name="key2">The value of the second part of the composite primary key used to match entities against.</param>
1078+
/// <param name="paths">The dot-separated list of related objects to return in the query results.</param>
1079+
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing the entity found.</returns>
1080+
Task<TEntity> FindAsync(TKey1 key1, TKey2 key2, params string[] paths);
1081+
10531082
/// <summary>
10541083
/// Asynchronously finds an entity with the given composite primary key values in the repository.
10551084
/// </summary>
@@ -1060,6 +1089,15 @@ public interface IReadOnlyRepository<TEntity, in TKey1, in TKey2> where TEntity
10601089
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing the entity found.</returns>
10611090
Task<TEntity> FindAsync(TKey1 key1, TKey2 key2, string[] paths, CancellationToken cancellationToken = new CancellationToken());
10621091

1092+
/// <summary>
1093+
/// Asynchronously finds an entity with the given composite primary key values in the repository.
1094+
/// </summary>
1095+
/// <param name="key1">The value of the first part of the composite primary key used to match entities against.</param>
1096+
/// <param name="key2">The value of the second part of the composite primary key used to match entities against.</param>
1097+
/// <param name="paths">A collection of lambda expressions representing the paths to include.</param>
1098+
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing the entity found.</returns>
1099+
Task<TEntity> FindAsync(TKey1 key1, TKey2 key2, params Expression<Func<TEntity, object>>[] paths);
1100+
10631101
/// <summary>
10641102
/// Asynchronously finds an entity with the given composite primary key values in the repository.
10651103
/// </summary>
@@ -1472,15 +1510,15 @@ public interface IReadOnlyRepository<TEntity, in TKey> where TEntity : class
14721510
/// <param name="key">The value of the primary key for the entity to be found.</param>
14731511
/// <param name="paths">The dot-separated list of related objects to return in the query results.</param>
14741512
/// <return>The entity found.</return>
1475-
TEntity Find(TKey key, string[] paths);
1513+
TEntity Find(TKey key, params string[] paths);
14761514

14771515
/// <summary>
14781516
/// Finds an entity with the given composite primary key values in the repository.
14791517
/// </summary>
14801518
/// <param name="key">The value of the primary key for the entity to be found.</param>
14811519
/// <param name="paths">A collection of lambda expressions representing the paths to include.</param>
14821520
/// <return>The entity found.</return>
1483-
TEntity Find(TKey key, Expression<Func<TEntity, object>>[] paths);
1521+
TEntity Find(TKey key, params Expression<Func<TEntity, object>>[] paths);
14841522

14851523
/// <summary>
14861524
/// Finds an entity with the given primary key value in the repository.
@@ -1671,6 +1709,14 @@ public interface IReadOnlyRepository<TEntity, in TKey> where TEntity : class
16711709
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing the entity found.</returns>
16721710
Task<TEntity> FindAsync(TKey key, CancellationToken cancellationToken = new CancellationToken());
16731711

1712+
/// <summary>
1713+
/// Asynchronously finds an entity with the given composite primary key values in the repository.
1714+
/// </summary>
1715+
/// <param name="key">The value of the primary key for the entity to be found.</param>
1716+
/// <param name="paths">The dot-separated list of related objects to return in the query results.</param>
1717+
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing the entity found.</returns>
1718+
Task<TEntity> FindAsync(TKey key, params string[] paths);
1719+
16741720
/// <summary>
16751721
/// Asynchronously finds an entity with the given composite primary key values in the repository.
16761722
/// </summary>
@@ -1680,6 +1726,14 @@ public interface IReadOnlyRepository<TEntity, in TKey> where TEntity : class
16801726
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing the entity found.</returns>
16811727
Task<TEntity> FindAsync(TKey key, string[] paths, CancellationToken cancellationToken = new CancellationToken());
16821728

1729+
/// <summary>
1730+
/// Asynchronously finds an entity with the given composite primary key values in the repository.
1731+
/// </summary>
1732+
/// <param name="key">The value of the primary key for the entity to be found.</param>
1733+
/// <param name="paths">A collection of lambda expressions representing the paths to include.</param>
1734+
/// <returns>The <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing the entity found.</returns>
1735+
Task<TEntity> FindAsync(TKey key, params Expression<Func<TEntity, object>>[] paths);
1736+
16831737
/// <summary>
16841738
/// Asynchronously finds an entity with the given composite primary key values in the repository.
16851739
/// </summary>

src/DotNetToolkit.Repository/Internal/ReadOnlyRepositoryWrapper.cs

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ public TEntity Find(TKey1 key1, TKey2 key2, TKey3 key3)
142142
return _underlyingRepo.Find(key1, key2, key3);
143143
}
144144

145-
public TEntity Find(TKey1 key1, TKey2 key2, TKey3 key3, string[] paths)
145+
public TEntity Find(TKey1 key1, TKey2 key2, TKey3 key3, params string[] paths)
146146
{
147147
return _underlyingRepo.Find(key1, key2, key3, paths);
148148
}
149149

150-
public TEntity Find(TKey1 key1, TKey2 key2, TKey3 key3, Expression<Func<TEntity, object>>[] paths)
150+
public TEntity Find(TKey1 key1, TKey2 key2, TKey3 key3, params Expression<Func<TEntity, object>>[] paths)
151151
{
152152
return _underlyingRepo.Find(key1, key2, key3, paths);
153153
}
@@ -272,11 +272,21 @@ public IPagedQueryResult<IEnumerable<TResult>> GroupBy<TGroupKey, TResult>(IQuer
272272
return _underlyingRepo.FindAsync(key1, key2, key3, cancellationToken);
273273
}
274274

275+
public Task<TEntity> FindAsync(TKey1 key1, TKey2 key2, TKey3 key3, params string[] paths)
276+
{
277+
return _underlyingRepo.FindAsync(key1, key2, key3, paths);
278+
}
279+
275280
public Task<TEntity> FindAsync(TKey1 key1, TKey2 key2, TKey3 key3, string[] paths, CancellationToken cancellationToken = new CancellationToken())
276281
{
277282
return _underlyingRepo.FindAsync(key1, key2, key3, paths, cancellationToken);
278283
}
279284

285+
public Task<TEntity> FindAsync(TKey1 key1, TKey2 key2, TKey3 key3, params Expression<Func<TEntity, object>>[] paths)
286+
{
287+
return _underlyingRepo.FindAsync(key1, key2, key3, paths);
288+
}
289+
280290
public Task<TEntity> FindAsync(TKey1 key1, TKey2 key2, TKey3 key3, Expression<Func<TEntity, object>>[] paths, CancellationToken cancellationToken = new CancellationToken())
281291
{
282292
return _underlyingRepo.FindAsync(key1, key2, key3, paths, cancellationToken);
@@ -529,12 +539,12 @@ public TEntity Find(TKey1 key1, TKey2 key2)
529539
return _underlyingRepo.Find(key1, key2);
530540
}
531541

532-
public TEntity Find(TKey1 key1, TKey2 key2, string[] paths)
542+
public TEntity Find(TKey1 key1, TKey2 key2, params string[] paths)
533543
{
534544
return _underlyingRepo.Find(key1, key2, paths);
535545
}
536546

537-
public TEntity Find(TKey1 key1, TKey2 key2, Expression<Func<TEntity, object>>[] paths)
547+
public TEntity Find(TKey1 key1, TKey2 key2, params Expression<Func<TEntity, object>>[] paths)
538548
{
539549
return _underlyingRepo.Find(key1, key2, paths);
540550
}
@@ -659,11 +669,21 @@ public IPagedQueryResult<IEnumerable<TResult>> GroupBy<TGroupKey, TResult>(IQuer
659669
return _underlyingRepo.FindAsync(key1, key2, cancellationToken);
660670
}
661671

672+
public Task<TEntity> FindAsync(TKey1 key1, TKey2 key2, params string[] paths)
673+
{
674+
return _underlyingRepo.FindAsync(key1, key2, paths);
675+
}
676+
662677
public Task<TEntity> FindAsync(TKey1 key1, TKey2 key2, string[] paths, CancellationToken cancellationToken = new CancellationToken())
663678
{
664679
return _underlyingRepo.FindAsync(key1, key2, paths, cancellationToken);
665680
}
666681

682+
public Task<TEntity> FindAsync(TKey1 key1, TKey2 key2, params Expression<Func<TEntity, object>>[] paths)
683+
{
684+
return _underlyingRepo.FindAsync(key1, key2, paths);
685+
}
686+
667687
public Task<TEntity> FindAsync(TKey1 key1, TKey2 key2, Expression<Func<TEntity, object>>[] paths, CancellationToken cancellationToken = new CancellationToken())
668688
{
669689
return _underlyingRepo.FindAsync(key1, key2, paths, cancellationToken);
@@ -916,12 +936,12 @@ public TEntity Find(TKey key)
916936
return _underlyingRepo.Find(key);
917937
}
918938

919-
public TEntity Find(TKey key, string[] paths)
939+
public TEntity Find(TKey key, params string[] paths)
920940
{
921941
return _underlyingRepo.Find(key, paths);
922942
}
923943

924-
public TEntity Find(TKey key, Expression<Func<TEntity, object>>[] paths)
944+
public TEntity Find(TKey key, params Expression<Func<TEntity, object>>[] paths)
925945
{
926946
return _underlyingRepo.Find(key, paths);
927947
}
@@ -1046,11 +1066,21 @@ public IPagedQueryResult<IEnumerable<TResult>> GroupBy<TGroupKey, TResult>(IQuer
10461066
return _underlyingRepo.FindAsync(key, cancellationToken);
10471067
}
10481068

1069+
public Task<TEntity> FindAsync(TKey key, params string[] paths)
1070+
{
1071+
return _underlyingRepo.FindAsync(key, paths);
1072+
}
1073+
10491074
public Task<TEntity> FindAsync(TKey key, string[] paths, CancellationToken cancellationToken = new CancellationToken())
10501075
{
10511076
return _underlyingRepo.FindAsync(key, paths, cancellationToken);
10521077
}
10531078

1079+
public Task<TEntity> FindAsync(TKey key, params Expression<Func<TEntity, object>>[] paths)
1080+
{
1081+
return _underlyingRepo.FindAsync(key, paths);
1082+
}
1083+
10541084
public Task<TEntity> FindAsync(TKey key, Expression<Func<TEntity, object>>[] paths, CancellationToken cancellationToken = new CancellationToken())
10551085
{
10561086
return _underlyingRepo.FindAsync(key, paths, cancellationToken);

0 commit comments

Comments
 (0)