Skip to content

Commit 6af42f7

Browse files
Merge pull request #686 from johelvisguzman/GH-681
(GH-681) Update QueryOptions naming convention
2 parents d31ff9c + 4c765e5 commit 6af42f7

File tree

20 files changed

+253
-253
lines changed

20 files changed

+253
-253
lines changed

benchmarks/DotNetToolkit.Repository.Performance/Benchmarks/Benchmarks.Repository.Find.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public void Setup()
1818
BaseSetup();
1919

2020
_defaultOptions = new QueryOptions<Customer>()
21-
.SatisfyBy(x => x.Name.Equals("Random Name"));
21+
.WithFilter(x => x.Name.Equals("Random Name"));
2222

23-
_pagingOptions = _defaultOptions.Page(1, 10);
23+
_pagingOptions = _defaultOptions.WithPage(1, 10);
2424

2525
_customer = new Customer { Id = new System.Random().Next(), Name = "Random Name" };
2626

benchmarks/DotNetToolkit.Repository.Performance/Benchmarks/Benchmarks.Repository.GroupBy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public void Setup()
1818
BaseSetup();
1919

2020
_defaultOptions = new QueryOptions<Customer>()
21-
.SatisfyBy(x => x.Name.Equals("Random Name"));
21+
.WithFilter(x => x.Name.Equals("Random Name"));
2222

23-
_pagingOptions = _defaultOptions.Page(1, 10);
23+
_pagingOptions = _defaultOptions.WithPage(1, 10);
2424

2525
_customer = new Customer { Id = new System.Random().Next(), Name = "Random Name" };
2626

benchmarks/DotNetToolkit.Repository.Performance/Benchmarks/Benchmarks.Repository.ToDictionary.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public void Setup()
1818
BaseSetup();
1919

2020
_defaultOptions = new QueryOptions<Customer>()
21-
.SatisfyBy(x => x.Name.Equals("Random Name"));
21+
.WithFilter(x => x.Name.Equals("Random Name"));
2222

23-
_pagingOptions = _defaultOptions.Page(1, 10);
23+
_pagingOptions = _defaultOptions.WithPage(1, 10);
2424

2525
_customer = new Customer { Id = new System.Random().Next(), Name = "Random Name" };
2626

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public async Task<TEntity> FindAsync<TEntity>(CancellationToken cancellationToke
322322
}
323323

324324
var options = new QueryOptions<TEntity>()
325-
.Include(Conventions.GetByPrimaryKeySpecification<TEntity>(keyValues));
325+
.WithFilter(Conventions.GetByPrimaryKeySpecification<TEntity>(keyValues));
326326

327327
var query = AsQueryable(fetchStrategy);
328328

src/DotNetToolkit.Repository.EntityFrameworkCore/Internal/EfCoreRepositoryContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public async Task<TEntity> FindAsync<TEntity>(CancellationToken cancellationToke
342342
}
343343

344344
var options = new QueryOptions<TEntity>()
345-
.Include(Conventions.GetByPrimaryKeySpecification<TEntity>(keyValues));
345+
.WithFilter(Conventions.GetByPrimaryKeySpecification<TEntity>(keyValues));
346346

347347
var query = AsQueryable(fetchStrategy);
348348

src/DotNetToolkit.Repository/Configuration/LinqEnumerableRepositoryContextBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public virtual TEntity Find<TEntity>([CanBeNull] IFetchQueryStrategy<TEntity> fe
232232
Guard.NotEmpty(keyValues, nameof(keyValues));
233233

234234
var options = new QueryOptions<TEntity>()
235-
.Include(Conventions.GetByPrimaryKeySpecification<TEntity>(keyValues));
235+
.WithFilter(Conventions.GetByPrimaryKeySpecification<TEntity>(keyValues));
236236

237237
var query = AsEnumerable(fetchStrategy);
238238

src/DotNetToolkit.Repository/Configuration/LinqQueryableRepositoryContextBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public virtual TEntity Find<TEntity>([CanBeNull] IFetchQueryStrategy<TEntity> fe
168168
Guard.NotEmpty(keyValues, nameof(keyValues));
169169

170170
var options = new QueryOptions<TEntity>()
171-
.Include(Conventions.GetByPrimaryKeySpecification<TEntity>(keyValues));
171+
.WithFilter(Conventions.GetByPrimaryKeySpecification<TEntity>(keyValues));
172172

173173
var query = AsQueryable<TEntity>(fetchStrategy);
174174

src/DotNetToolkit.Repository/Extensions/QueryOptionsExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static IFetchQueryStrategy<T> DefaultIfFetchStrategyEmpty<T>([CanBeNull]
3838
/// <returns>The new query options instance.</returns>
3939
public static IQueryOptions<T> ToQueryOptions<T>([NotNull] this Expression<Func<T, bool>> predicate)
4040
{
41-
return new QueryOptions<T>().SatisfyBy(Guard.NotNull(predicate, nameof(predicate)));
41+
return new QueryOptions<T>().WithFilter(Guard.NotNull(predicate, nameof(predicate)));
4242
}
4343
}
4444
}

src/DotNetToolkit.Repository/Query/QueryOptions.cs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ public QueryOptions<T> Clone()
5454
{
5555
var copy = new QueryOptions<T>();
5656

57-
if (this._fetchStrategy != null)
58-
copy.Include(this._fetchStrategy);
57+
if (_fetchStrategy != null)
58+
copy.WithFetch(_fetchStrategy);
5959

60-
if (this._specificationStrategy != null)
61-
copy.Include(this._specificationStrategy);
60+
if (_specificationStrategy != null)
61+
copy.WithFilter(_specificationStrategy);
6262

63-
copy._sortingPropertiesMapping = this._sortingPropertiesMapping.ToDictionary(x => x.Key, x => x.Value);
64-
copy._pageIndex = this._pageIndex;
65-
copy._pageSize = this._pageSize;
63+
copy._sortingPropertiesMapping = _sortingPropertiesMapping.ToDictionary(x => x.Key, x => x.Value);
64+
copy._pageIndex = _pageIndex;
65+
copy._pageSize = _pageSize;
6666

6767
return copy;
6868
}
@@ -72,7 +72,7 @@ public QueryOptions<T> Clone()
7272
/// </summary>
7373
/// <param name="propertyName">The name of the property.</param>
7474
/// <returns>The current instance.</returns>
75-
public QueryOptions<T> OrderBy([NotNull] string propertyName)
75+
public QueryOptions<T> WithSortBy([NotNull] string propertyName)
7676
{
7777
Guard.NotEmpty(propertyName, nameof(propertyName));
7878

@@ -89,7 +89,7 @@ public QueryOptions<T> OrderBy([NotNull] string propertyName)
8989
/// </summary>
9090
/// <param name="propertyName">The name of the property.</param>
9191
/// <returns>The current instance.</returns>
92-
public QueryOptions<T> OrderByDescending([NotNull] string propertyName)
92+
public QueryOptions<T> WithSortByDescending([NotNull] string propertyName)
9393
{
9494
Guard.NotEmpty(propertyName, nameof(propertyName));
9595

@@ -106,19 +106,19 @@ public QueryOptions<T> OrderByDescending([NotNull] string propertyName)
106106
/// </summary>
107107
/// <param name="property">The sorting property expression.</param>
108108
/// <returns>The current instance.</returns>
109-
public QueryOptions<T> OrderBy([NotNull] Expression<Func<T, object>> property)
109+
public QueryOptions<T> WithSortBy([NotNull] Expression<Func<T, object>> property)
110110
{
111-
return OrderBy(ExpressionHelper.GetPropertyPath(Guard.NotNull(property, nameof(property))));
111+
return WithSortBy(ExpressionHelper.GetPropertyPath(Guard.NotNull(property, nameof(property))));
112112
}
113113

114114
/// <summary>
115115
/// Applies a descending sort order according to the specified property name.
116116
/// </summary>
117117
/// <param name="property">The sorting property expression.</param>
118118
/// <returns>The current instance.</returns>
119-
public QueryOptions<T> OrderByDescending([NotNull] Expression<Func<T, object>> property)
119+
public QueryOptions<T> WithSortByDescending([NotNull] Expression<Func<T, object>> property)
120120
{
121-
return OrderByDescending(ExpressionHelper.GetPropertyPath(Guard.NotNull(property, nameof(property))));
121+
return WithSortByDescending(ExpressionHelper.GetPropertyPath(Guard.NotNull(property, nameof(property))));
122122
}
123123

124124
/// <summary>
@@ -127,7 +127,7 @@ public QueryOptions<T> OrderByDescending([NotNull] Expression<Func<T, object>> p
127127
/// <param name="pageIndex">The zero-based index of the data page to retrieve.</param>
128128
/// <param name="pageSize">The number of rows of the data page to retrieve.</param>
129129
/// <returns>The current instance.</returns>
130-
public QueryOptions<T> Page(int pageIndex, int pageSize)
130+
public QueryOptions<T> WithPage(int pageIndex, int pageSize)
131131
{
132132
if (pageIndex < 1)
133133
throw new ArgumentOutOfRangeException(nameof(pageIndex), "Cannot be lower than 1.");
@@ -146,19 +146,19 @@ public QueryOptions<T> Page(int pageIndex, int pageSize)
146146
/// </summary>
147147
/// <param name="pageIndex">The zero-based index of the data page to retrieve.</param>
148148
/// <returns>The current instance.</returns>
149-
public QueryOptions<T> Page(int pageIndex)
149+
public QueryOptions<T> WithPage(int pageIndex)
150150
{
151151
var pageSize = _pageSize == -1 ? DefaultPageSize : _pageSize;
152152

153-
return Page(pageIndex, pageSize);
153+
return WithPage(pageIndex, pageSize);
154154
}
155155

156156
/// <summary>
157157
/// Includes a specification strategy/criteria that is used for matching entities against and combine it with the current specified predicate using the logical "and".
158158
/// </summary>
159159
/// <param name="criteria">The specification criteria that is used for matching entities against.</param>
160160
/// <returns>The current instance.</returns>
161-
public QueryOptions<T> Include([NotNull] ISpecificationQueryStrategy<T> criteria)
161+
public QueryOptions<T> WithFilter([NotNull] ISpecificationQueryStrategy<T> criteria)
162162
{
163163
Guard.NotNull(criteria, nameof(criteria));
164164

@@ -174,7 +174,7 @@ public QueryOptions<T> Include([NotNull] ISpecificationQueryStrategy<T> criteria
174174
/// </summary>
175175
/// <param name="predicate">A function to filter each entity.</param>
176176
/// <returns>The current instance.</returns>
177-
public QueryOptions<T> SatisfyBy([NotNull] Expression<Func<T, bool>> predicate)
177+
public QueryOptions<T> WithFilter([NotNull] Expression<Func<T, bool>> predicate)
178178
{
179179
Guard.NotNull(predicate, nameof(predicate));
180180

@@ -190,11 +190,11 @@ public QueryOptions<T> SatisfyBy([NotNull] Expression<Func<T, bool>> predicate)
190190
/// </summary>
191191
/// <param name="fetchStrategy">Defines the child objects that should be retrieved when loading the entity.</param>
192192
/// <returns>The current instance.</returns>
193-
public QueryOptions<T> Include([NotNull] IFetchQueryStrategy<T> fetchStrategy)
193+
public QueryOptions<T> WithFetch([NotNull] IFetchQueryStrategy<T> fetchStrategy)
194194
{
195195
Guard.NotNull(fetchStrategy, nameof(fetchStrategy));
196196

197-
var paths = _fetchStrategy != null ? ((IFetchQueryStrategy<T>)_fetchStrategy).PropertyPaths : new List<string>();
197+
var paths = _fetchStrategy != null ? _fetchStrategy.PropertyPaths : new List<string>();
198198
var mergedPaths = paths.Union(fetchStrategy.PropertyPaths).ToList();
199199

200200
_fetchStrategy = _fetchStrategy ?? new FetchQueryStrategy<T>();
@@ -209,7 +209,7 @@ public QueryOptions<T> Include([NotNull] IFetchQueryStrategy<T> fetchStrategy)
209209
/// </summary>
210210
/// <param name="path">The dot-separated list of related objects to return in the query results.</param>
211211
/// <returns>The current instance.</returns>
212-
public QueryOptions<T> Fetch([NotNull] string path)
212+
public QueryOptions<T> WithFetch([NotNull] string path)
213213
{
214214
Guard.NotEmpty(path, nameof(path));
215215

@@ -225,9 +225,9 @@ public QueryOptions<T> Fetch([NotNull] string path)
225225
/// </summary>
226226
/// <param name="path">A lambda expression representing the path to include.</param>
227227
/// <returns>The current instance.</returns>
228-
public QueryOptions<T> Fetch([NotNull] Expression<Func<T, object>> path)
228+
public QueryOptions<T> WithFetch([NotNull] Expression<Func<T, object>> path)
229229
{
230-
return Fetch(Guard.NotNull(path, nameof(path)).ToIncludeString());
230+
return WithFetch(Guard.NotNull(path, nameof(path)).ToIncludeString());
231231
}
232232

233233
#endregion

test/DotNetToolkit.Repository.Integration.Test/Tests/CachingProvider/RepositoryCachingTests.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ private static void TestFindWithOptions(IRepositoryFactory repoFactory)
401401

402402
repo.Add(customer);
403403

404-
var queryOptions = new QueryOptions<Customer>().SatisfyBy(x => x.Id == customer.Id);
404+
var queryOptions = new QueryOptions<Customer>().WithFilter(x => x.Id == customer.Id);
405405

406406
Assert.True(repo.CacheEnabled);
407407
Assert.False(repo.CacheUsed);
@@ -453,7 +453,7 @@ private static void TestFindAllWithOptions(IRepositoryFactory repoFactory)
453453

454454
repo.Add(customer);
455455

456-
var queryOptions = new QueryOptions<Customer>().SatisfyBy(x => x.Id == customer.Id);
456+
var queryOptions = new QueryOptions<Customer>().WithFilter(x => x.Id == customer.Id);
457457

458458
Assert.True(repo.CacheEnabled);
459459
Assert.False(repo.CacheUsed);
@@ -505,7 +505,7 @@ private static void TestCountWithOptions(IRepositoryFactory repoFactory)
505505

506506
repo.Add(customer);
507507

508-
var queryOptions = new QueryOptions<Customer>().SatisfyBy(x => x.Id == customer.Id);
508+
var queryOptions = new QueryOptions<Customer>().WithFilter(x => x.Id == customer.Id);
509509

510510
Assert.True(repo.CacheEnabled);
511511
Assert.False(repo.CacheUsed);
@@ -557,7 +557,7 @@ private static void TestExistsWithOptions(IRepositoryFactory repoFactory)
557557

558558
repo.Add(customer);
559559

560-
var queryOptions = new QueryOptions<Customer>().SatisfyBy(x => x.Id == customer.Id);
560+
var queryOptions = new QueryOptions<Customer>().WithFilter(x => x.Id == customer.Id);
561561

562562
Assert.True(repo.CacheEnabled);
563563
Assert.False(repo.CacheUsed);
@@ -609,7 +609,7 @@ private static void TestToDictionaryWithOptions(IRepositoryFactory repoFactory)
609609

610610
repo.Add(customer);
611611

612-
var queryOptions = new QueryOptions<Customer>().SatisfyBy(x => x.Id == customer.Id);
612+
var queryOptions = new QueryOptions<Customer>().WithFilter(x => x.Id == customer.Id);
613613

614614
Assert.True(repo.CacheEnabled);
615615
Assert.False(repo.CacheUsed);
@@ -661,7 +661,7 @@ private static void TestGroupByWithOptions(IRepositoryFactory repoFactory)
661661

662662
repo.Add(customer);
663663

664-
var queryOptions = new QueryOptions<Customer>().SatisfyBy(x => x.Id == customer.Id);
664+
var queryOptions = new QueryOptions<Customer>().WithFilter(x => x.Id == customer.Id);
665665

666666
Assert.True(repo.CacheEnabled);
667667
Assert.False(repo.CacheUsed);
@@ -800,7 +800,7 @@ private static async Task TestFindWithOptionsAsync(IRepositoryFactory repoFactor
800800

801801
await repo.AddAsync(customer);
802802

803-
var queryOptions = new QueryOptions<Customer>().SatisfyBy(x => x.Id == customer.Id);
803+
var queryOptions = new QueryOptions<Customer>().WithFilter(x => x.Id == customer.Id);
804804

805805
Assert.True(repo.CacheEnabled);
806806
Assert.False(repo.CacheUsed);
@@ -852,7 +852,7 @@ private static async Task TestFindAllWithOptionsAsync(IRepositoryFactory repoFac
852852

853853
await repo.AddAsync(customer);
854854

855-
var queryOptions = new QueryOptions<Customer>().SatisfyBy(x => x.Id == customer.Id);
855+
var queryOptions = new QueryOptions<Customer>().WithFilter(x => x.Id == customer.Id);
856856

857857
Assert.True(repo.CacheEnabled);
858858
Assert.False(repo.CacheUsed);
@@ -904,7 +904,7 @@ private static async Task TestCountWithOptionsAsync(IRepositoryFactory repoFacto
904904

905905
await repo.AddAsync(customer);
906906

907-
var queryOptions = new QueryOptions<Customer>().SatisfyBy(x => x.Id == customer.Id);
907+
var queryOptions = new QueryOptions<Customer>().WithFilter(x => x.Id == customer.Id);
908908

909909
Assert.True(repo.CacheEnabled);
910910
Assert.False(repo.CacheUsed);
@@ -956,7 +956,7 @@ private static async Task TestExistsWithOptionsAsync(IRepositoryFactory repoFact
956956

957957
await repo.AddAsync(customer);
958958

959-
var queryOptions = new QueryOptions<Customer>().SatisfyBy(x => x.Id == customer.Id);
959+
var queryOptions = new QueryOptions<Customer>().WithFilter(x => x.Id == customer.Id);
960960

961961
Assert.True(repo.CacheEnabled);
962962
Assert.False(repo.CacheUsed);
@@ -1008,7 +1008,7 @@ private static async Task TestToDictionaryWithOptionsAsync(IRepositoryFactory re
10081008

10091009
await repo.AddAsync(customer);
10101010

1011-
var queryOptions = new QueryOptions<Customer>().SatisfyBy(x => x.Id == customer.Id);
1011+
var queryOptions = new QueryOptions<Customer>().WithFilter(x => x.Id == customer.Id);
10121012

10131013
Assert.True(repo.CacheEnabled);
10141014
Assert.False(repo.CacheUsed);
@@ -1060,7 +1060,7 @@ private static async Task TestGroupByWithOptionsAsync(IRepositoryFactory repoFac
10601060

10611061
await repo.AddAsync(customer);
10621062

1063-
var queryOptions = new QueryOptions<Customer>().SatisfyBy(x => x.Id == customer.Id);
1063+
var queryOptions = new QueryOptions<Customer>().WithFilter(x => x.Id == customer.Id);
10641064

10651065
Assert.True(repo.CacheEnabled);
10661066
Assert.False(repo.CacheUsed);

0 commit comments

Comments
 (0)