Skip to content

Commit 4d80498

Browse files
v2.5.0 (#61)
* Support multiple target frameworks * bump to 2.5.0 * add husky formatter * update dependencies * fix multiple target ef dependencies * Child element property query (#60) * add some tests for SubClass feature * add sunyuliang Co-authored-by: sunyuliang <sun_yuliang@foxmail.com>
1 parent 1342211 commit 4d80498

19 files changed

Lines changed: 284 additions & 122 deletions

.config/dotnet-tools.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"husky": {
6+
"version": "0.0.8",
7+
"commands": [
8+
"husky"
9+
]
10+
},
11+
"dotnet-format": {
12+
"version": "5.1.250801",
13+
"commands": [
14+
"dotnet-format"
15+
]
16+
}
17+
}
18+
}

.editorconfig

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@ indent_size = 3
66
charset = utf-8
77
trim_trailing_whitespace = true
88
insert_final_newline = true
9+
tab_width = 3
910

1011
# Microsoft .NET properties
11-
csharp_new_line_before_members_in_object_initializers = false
12-
csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion
13-
csharp_style_var_elsewhere = true:suggestion
14-
csharp_style_var_for_built_in_types = true:suggestion
15-
csharp_style_var_when_type_is_apparent = true:suggestion
1612
dotnet_naming_rule.unity_serialized_field_rule.import_to_resharper = True
1713
dotnet_naming_rule.unity_serialized_field_rule.resharper_description = Unity serialized field
1814
dotnet_naming_rule.unity_serialized_field_rule.resharper_guid = 5f0fdb63-c892-4d2c-9324-15c80b22a7ef
@@ -61,7 +57,12 @@ resharper_web_config_module_not_resolved_highlighting = warning
6157
resharper_web_config_type_not_resolved_highlighting = warning
6258
resharper_web_config_wrong_module_highlighting = warning
6359

64-
[*.{appxmanifest,asax,ascx,aspx,axaml,build,cg,cginc,compute,cs,cshtml,dtd,fs,fsi,fsscript,fsx,hlsl,hlsli,hlslinc,master,ml,mli,nuspec,paml,razor,resw,resx,shader,skin,usf,ush,vb,xaml,xamlx,xoml,xsd}]
65-
indent_style = space
66-
indent_size = 3
67-
tab_width = 3
60+
61+
[*.cs]
62+
csharp_new_line_before_members_in_object_initializers = false
63+
csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion
64+
csharp_style_var_elsewhere = true:suggestion
65+
csharp_style_var_for_built_in_types = true:suggestion
66+
csharp_style_var_when_type_is_apparent = true:suggestion
67+
csharp_space_after_cast = false
68+
csharp_indent_case_contents_when_block = false

.husky/pre-commit

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
## husky task runner examples -------------------
5+
## note : for local installation use 'dotnet husky'
6+
7+
## run all tasks
8+
#husky run
9+
10+
### run all tasks with group: 'group-name'
11+
#husky run --group group-name
12+
13+
## run task with name: 'task-name'
14+
#husky run --name task-name
15+
16+
## or put your custom commands -------------------
17+
#echo 'Husky.Net is awesome!'
18+
19+
dotnet husky run

.husky/task-runner.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"tasks": [
3+
{
4+
"command": "dotnet-format",
5+
"args": [
6+
"--include",
7+
"${staged}"
8+
],
9+
"include": [
10+
"**/*.cs",
11+
"**/*.vb"
12+
]
13+
},
14+
{
15+
"name": "Welcome",
16+
"command": "bash",
17+
"args": [
18+
"-c",
19+
"echo Great work! 🥂"
20+
],
21+
"windows": {
22+
"command": "cmd",
23+
"args": [
24+
"/c",
25+
"echo Great work! 🥂"
26+
]
27+
}
28+
}
29+
]
30+
}

docs/contribution/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ check out the [github contributing guide](https://git-scm.com/book/en/v2/GitHub-
4545

4646
- [AliReZa Sabouri](https://github.com/alirezanet)
4747
- [Alireza Arabshahi](https://github.com/AlirezaArabshahi)
48+
- [sunyuliang](https://github.com/sunyuliang)
4849
- Add your name

src/Gridify.EntityFramework/Gridify.EntityFramework.csproj

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netstandard2.0</TargetFramework>
43
<PackageId>Gridify.EntityFramework</PackageId>
54
<Version>2.4.8</Version>
65
<Authors>Alireza Sabouri</Authors>
@@ -15,6 +14,10 @@
1514
<IncludeSymbols>true</IncludeSymbols>
1615
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1716
<PackageReadmeFile>README.md</PackageReadmeFile>
17+
<TargetFrameworks>net5.0;net6.0;netstandard2.0;netstandard2.1</TargetFrameworks>
18+
<LangVersion>default</LangVersion>
19+
<Nullable>enable</Nullable>
20+
<PackageVersion>2.5.0</PackageVersion>
1821
</PropertyGroup>
1922

2023
<ItemGroup>
@@ -24,6 +27,15 @@
2427

2528
<ItemGroup>
2629
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
27-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.3" />
30+
</ItemGroup>
31+
32+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
33+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.*" />
34+
</ItemGroup>
35+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1' Or '$(TargetFramework)' == 'net5.0'">
36+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.*" />
37+
</ItemGroup>
38+
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
39+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.*" />
2840
</ItemGroup>
2941
</Project>

src/Gridify.EntityFramework/GridifyExtensions.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
using System.Threading;
33
using System.Threading.Tasks;
44
using Microsoft.EntityFrameworkCore;
5+
// ReSharper disable MemberCanBePrivate.Global
56

67
namespace Gridify.EntityFramework
78
{
9+
// ReSharper disable once PartialTypeWithSinglePart
810
public static partial class GridifyExtensions
911
{
1012
#region "EntityFramework Integration"
1113

12-
public async static Task<QueryablePaging<T>> GridifyQueryableAsync<T>(this IQueryable<T> query, IGridifyQuery gridifyQuery,
13-
IGridifyMapper<T> mapper)
14+
public static async Task<QueryablePaging<T>> GridifyQueryableAsync<T>(this IQueryable<T> query, IGridifyQuery gridifyQuery,
15+
IGridifyMapper<T>? mapper)
1416
{
1517
query = query.ApplyFiltering(gridifyQuery, mapper);
1618
var count = await query.CountAsync();
@@ -19,14 +21,14 @@ public async static Task<QueryablePaging<T>> GridifyQueryableAsync<T>(this IQuer
1921
return new QueryablePaging<T>(count, query);
2022
}
2123

22-
public static async Task<Paging<T>> GridifyAsync<T>(this IQueryable<T> query, IGridifyQuery gridifyQuery, IGridifyMapper<T> mapper = null)
24+
public static async Task<Paging<T>> GridifyAsync<T>(this IQueryable<T> query, IGridifyQuery gridifyQuery, IGridifyMapper<T>? mapper = null)
2325
{
2426
var (count, queryable) = await query.GridifyQueryableAsync(gridifyQuery, mapper);
2527
return new Paging<T>(count, await queryable.ToListAsync());
2628
}
2729

28-
public async static Task<QueryablePaging<T>> GridifyQueryableAsync<T>(this IQueryable<T> query, IGridifyQuery gridifyQuery,
29-
IGridifyMapper<T> mapper, CancellationToken token)
30+
public static async Task<QueryablePaging<T>> GridifyQueryableAsync<T>(this IQueryable<T> query, IGridifyQuery gridifyQuery,
31+
IGridifyMapper<T>? mapper, CancellationToken token)
3032
{
3133
query = query.ApplyFiltering(gridifyQuery, mapper);
3234
var count = await query.CountAsync(token);
@@ -36,7 +38,7 @@ public async static Task<QueryablePaging<T>> GridifyQueryableAsync<T>(this IQuer
3638
}
3739

3840
public static async Task<Paging<T>> GridifyAsync<T>(this IQueryable<T> query, IGridifyQuery gridifyQuery, CancellationToken token,
39-
IGridifyMapper<T> mapper = null)
41+
IGridifyMapper<T>? mapper = null)
4042
{
4143
var (count, queryable) = await query.GridifyQueryableAsync(gridifyQuery, mapper, token);
4244
return new Paging<T>(count, await queryable.ToListAsync(token));

src/Gridify/Gridify.csproj

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
54
<PackageId>Gridify</PackageId>
65
<Version>2.4.8</Version>
76
<Authors>Alireza Sabouri</Authors>
@@ -19,17 +18,24 @@
1918
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2019
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2120
<PackageReadmeFile>README.md</PackageReadmeFile>
21+
<TargetFrameworks>net5.0;net6.0;netstandard2.0;netstandard2.1</TargetFrameworks>
22+
<PackageVersion>2.5.0</PackageVersion>
2223

2324
</PropertyGroup>
2425

2526
<ItemGroup>
26-
<None Include="..\..\README.md" Pack="true" PackagePath="\"/>
27+
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
2728
</ItemGroup>
2829

2930
<ItemGroup>
30-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
31-
<PackageReference Include="System.Reflection.Emit" Version="4.7.0"/>
31+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
32+
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
3233
</ItemGroup>
3334

35+
<Target Name="husky" BeforeTargets="Restore;CollectPackageReferences" Condition="'$(IsCrossTargetingBuild)' == 'true'">
36+
<Exec Command="dotnet tool restore" StandardOutputImportance="Low" StandardErrorImportance="High"/>
37+
<Exec Command="dotnet husky install" StandardOutputImportance="Low" StandardErrorImportance="High"
38+
WorkingDirectory="../../" /> <!--Update this to the releative path to your project root dir -->
39+
</Target>
3440

3541
</Project>

src/Gridify/GridifyMapper.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#nullable enable
1+
#nullable enable
22
using System;
33
using System.Collections.Generic;
44
using System.Linq;
@@ -170,11 +170,15 @@ internal static Expression<Func<T, object>> CreateExpression(string from)
170170
{
171171
// x =>
172172
var parameter = Expression.Parameter(typeof(T));
173-
// x.Name
174-
var mapProperty = Expression.Property(parameter, from);
173+
// x.Name,x.yyy.zz.xx
174+
Expression mapProperty = parameter;
175+
foreach (var propertyName in from.Split('.'))
176+
{
177+
mapProperty = Expression.Property(mapProperty, propertyName);
178+
}
175179
// (object)x.Name
176180
var convertedExpression = Expression.Convert(mapProperty, typeof(object));
177181
// x => (object)x.Name
178182
return Expression.Lambda<Func<T, object>>(convertedExpression, parameter);
179183
}
180-
}
184+
}

src/Gridify/GridifyMapperConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ public record GridifyMapperConfiguration
2121
/// Default is false
2222
/// </summary>
2323
public bool IgnoreNotMappedFields { get; set; } = GridifyGlobalConfiguration.IgnoreNotMappedFields;
24+
2425
}
2526

0 commit comments

Comments
 (0)