Skip to content

Commit 8c78a90

Browse files
MnatsakanMargaryanMnatsakanMargaryan
authored andcommitted
Refactor QueryableExtensions and update version
Replaced CreateSelector<TEntity> with mapper.GetExpression in QueryableExtensions.cs. Removed CreateSelector<TEntity> method. Updated project version to 1.5.2 in GridifyExtensions.csproj.
1 parent 5347a1c commit 8c78a90

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

src/GridifyExtensions/Extensions/QueryableExtensions.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static async Task<PagedResponse<object>> ColumnDistinctValuesAsync<TEntit
8787

8888
var item = await query
8989
.ApplyFiltering(model, mapper)
90-
.Select(CreateSelector<TEntity>(model.PropertyName))
90+
.Select(mapper.GetExpression(model.PropertyName))
9191
.FirstOrDefaultAsync(cancellationToken);
9292

9393
if (item is null)
@@ -123,7 +123,7 @@ public static async Task<CursoredResponse<object>> ColumnDistinctValuesAsync<TEn
123123

124124
var item = await query
125125
.ApplyFiltering(gridifyModel, mapper)
126-
.Select(CreateSelector<TEntity>(model.PropertyName))
126+
.Select(mapper.GetExpression(model.PropertyName))
127127
.FirstOrDefaultAsync(cancellationToken);
128128

129129
if (item is null)
@@ -172,13 +172,4 @@ public static IEnumerable<MappingModel> GetMappings<TEntity>()
172172
: x.To.Body.Type.Name,
173173
});
174174
}
175-
176-
private static Expression<Func<T, object>> CreateSelector<T>(string propertyName)
177-
{
178-
var parameter = Expression.Parameter(typeof(T), "x");
179-
var property = Expression.Property(parameter, propertyName);
180-
var converted = Expression.Convert(property, typeof(object));
181-
182-
return Expression.Lambda<Func<T, object>>(converted, parameter);
183-
}
184175
}

src/GridifyExtensions/GridifyExtensions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PackageReadmeFile>Readme.md</PackageReadmeFile>
99
<Authors>Pandatech</Authors>
1010
<Copyright>MIT</Copyright>
11-
<Version>1.5.1</Version>
11+
<Version>1.5.2</Version>
1212
<PackageId>Pandatech.GridifyExtensions</PackageId>
1313
<Title>Pandatech.Gridify.Extensions</Title>
1414
<PackageTags>Pandatech, library, Gridify, Pagination, Filters</PackageTags>

0 commit comments

Comments
 (0)