├── .gitattributes
├── .github
└── workflows
│ ├── publish-docs.yml
│ └── publish.yml
├── .gitignore
├── EasyAbp.Abp.RelatedDtoLoader.sln
├── EasyAbp.Abp.RelatedDtoLoader.sln.DotSettings
├── LICENSE
├── README.md
├── common.props
├── docs
├── CustomDtoSource.md
└── README.md
├── nupkg
├── common.ps1
├── pack.ps1
└── push_packages.ps1
├── src
├── EasyAbp.Abp.RelatedDtoLoader.Abstractions
│ ├── EasyAbp.Abp.RelatedDtoLoader.Abstractions.csproj
│ ├── EasyAbp
│ │ └── Abp
│ │ │ └── RelatedDtoLoader
│ │ │ └── RelatedDtoAttribute.cs
│ ├── FodyWeavers.xml
│ └── FodyWeavers.xsd
└── EasyAbp.Abp.RelatedDtoLoader
│ ├── EasyAbp.Abp.RelatedDtoLoader.csproj
│ ├── EasyAbp
│ └── Abp
│ │ └── RelatedDtoLoader
│ │ ├── AbpRelatedDtoLoaderModule.cs
│ │ ├── Configurations
│ │ ├── DtoLoaderConfiguration.cs
│ │ ├── DtoLoaderConfigurationExpression.cs
│ │ ├── IDtoLoaderConfigurationProvider.cs
│ │ ├── IRelatedDtoLoaderConfigurationContext.cs
│ │ ├── RelatedDtoLoaderAssemblyOptions.cs
│ │ ├── RelatedDtoLoaderConfigurationContext.cs
│ │ └── RelatedDtoLoaderOptions.cs
│ │ ├── DtoLoadRule
│ │ ├── DtoLoadRule.cs
│ │ └── IDtoLoadRule.cs
│ │ ├── Exceptions
│ │ ├── MissingIdPropertyNameException.cs
│ │ └── UnsupportedTargetTypeException.cs
│ │ ├── RelatedDtoLoader
│ │ ├── IRelatedDtoLoader.cs
│ │ ├── RelatedDtoLoader.cs
│ │ └── RelatedDtoLoaderExtensions.cs
│ │ ├── RelatedDtoLoaderProfile
│ │ ├── IRelatedDtoLoaderProfile.cs
│ │ └── RelatedDtoLoaderProfile.cs
│ │ └── RelatedDtoProperty
│ │ ├── RelatedDtoProperty.cs
│ │ ├── RelatedDtoPropertyCollection.cs
│ │ └── RelatedValueType.cs
│ ├── FodyWeavers.xml
│ └── FodyWeavers.xsd
└── test
├── EasyAbp.Abp.RelatedDtoLoader.IntegratedTests
├── EasyAbp.Abp.RelatedDtoLoader.IntegratedTests.csproj
├── GuidKey
│ ├── MyGuidDbContext.cs
│ ├── MyGuidEntityFrameworkCoreTestModule.cs
│ ├── MyGuidRelatedDtoLoaderProfile.cs
│ ├── MyGuidRelatedDtoLoaderTestModule.cs
│ ├── MyGuidTestAutoMapperProfile.cs
│ ├── MyGuidTestData.cs
│ ├── MyGuidTestDataBuilder.cs
│ └── Tests
│ │ └── RelatedDtoLoader_Basic_Test_Guid.cs
├── IntegerKey
│ ├── MyIntegerDbContext.cs
│ ├── MyIntegerEntityFrameworkCoreTestModule.cs
│ ├── MyIntegerRelatedDtoLoaderProfile.cs
│ ├── MyIntegerRelatedDtoLoaderTestModule.cs
│ ├── MyIntegerTestAutoMapperProfile.cs
│ ├── MyIntegerTestData.cs
│ ├── MyIntegerTestDataBuilder.cs
│ └── Tests
│ │ └── RelatedDtoLoader_Basic_Test_Integer.cs
└── RelatedDtoLoaderTestBase.cs
├── EasyAbp.Abp.RelatedDtoLoader.TestBase
├── Application
│ ├── IProductAppService.cs
│ └── ProductAppService.cs
├── Domain
│ ├── IntegerKey
│ │ ├── IntOrder.cs
│ │ ├── IntOrderDto.cs
│ │ ├── IntProduct.cs
│ │ └── IntProductDto.cs
│ ├── Order.cs
│ ├── OrderDto.cs
│ ├── Product.cs
│ ├── ProductCommentDto.cs
│ ├── ProductDto.cs
│ └── UnsupportedOrderDto.cs
├── EasyAbp.Abp.RelatedDtoLoader.TestBase.csproj
└── RelatedDtoLoaderTestBaseModule.cs
└── EasyAbp.Abp.RelatedDtoLoader.UnitTests
├── EasyAbp.Abp.RelatedDtoLoader.UnitTests.csproj
├── Loader
├── MyUnitTestDtoLoaderProfile.cs
├── RelatedDtoLoaderConfigurationTest.cs
└── RelatedDtoLoaderTest.cs
├── MyUnitTestData.cs
└── obj
└── Release
└── netcoreapp3.1
└── EasyAbp.Abp.RelatedDtoLoader.UnitTests.AssemblyInfo.cs
/.gitattributes:
--------------------------------------------------------------------------------
1 | **/wwwroot/libs/** linguist-vendored
2 |
--------------------------------------------------------------------------------
/.github/workflows/publish-docs.yml:
--------------------------------------------------------------------------------
1 | name: publish to easyabp.io
2 | on:
3 | push:
4 | branches:
5 | - master
6 | jobs:
7 | publish:
8 | runs-on: ubuntu-latest
9 | steps:
10 | - name: Checkout
11 | uses: actions/checkout@v2
12 | with:
13 | persist-credentials: false
14 | fetch-depth: 0
15 |
16 | - name: Find and Replace
17 | uses: jacobtomlinson/gha-find-replace@master
18 | with:
19 | find: \]\((/docs/)
20 | replace: "](/modules/${{ github.event.repository.name }}/"
21 | include: docs/
22 |
23 | - name: Pull repo and change files
24 | id: change
25 | run: |
26 | ls
27 | git clone https://github.com/EasyAbp/easyabp.github.io
28 | cd easyabp.github.io
29 | rm -rf docs/modules/${{ github.event.repository.name }}
30 | rm -rf docs/.vuepress/public/modules/${{ github.event.repository.name }}
31 | cp -rf ../docs/ docs/modules/${{ github.event.repository.name }}
32 | cp -rf ../docs/ docs/.vuepress/public/modules/${{ github.event.repository.name }}
33 | git add --all
34 | echo "##[set-output name=diff;]$(git diff --staged)"
35 | - name: Commit files
36 | if: steps.change.outputs.diff
37 | run: |
38 | ls
39 | cd easyabp.github.io
40 | git config --local user.email "action@github.com"
41 | git config --local user.name "GitHub Action"
42 | git commit -m "Update the docs of ${{ github.event.repository.name }}" -a
43 | - name: Push changes
44 | if: steps.change.outputs.diff
45 | uses: ad-m/github-push-action@master
46 | with:
47 | github_token: ${{ secrets.EASYABP_IO_ACCESS_TOKEN }}
48 | repository: EasyAbp/easyabp.github.io
49 | directory: easyabp.github.io
50 |
--------------------------------------------------------------------------------
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | name: publish to nuget
2 | on:
3 | push:
4 | branches:
5 | - master
6 | - main
7 | jobs:
8 | publish:
9 | runs-on: windows-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - uses: NuGet/setup-nuget@v1.0.5
13 |
14 | - name: read common.props
15 | id: commonProps
16 | uses: juliangruber/read-file-action@v1
17 | with:
18 | path: ./common.props
19 |
20 | - name: get version
21 | id: getVersion
22 | uses: AsasInnab/regex-action@v1
23 | with:
24 | regex_pattern: '(?<=>)[^<>]+(?=)'
25 | regex_flags: 'gim'
26 | search_string: '${{ steps.commonProps.outputs.content }}'
27 |
28 | - name: dotnet build
29 | run: dotnet build -c Release
30 |
31 | - name: dotnet pack
32 | run: dotnet pack -c Release --no-build -o dest
33 |
34 | - name: remove unused packages
35 | run: |
36 | cd dest
37 | del * -Exclude EasyAbp.*
38 | del * -Exclude *.${{ steps.getVersion.outputs.first_match }}.nupkg
39 | del *.HttpApi.Client.ConsoleTestApp*
40 | del *.Host.Shared*
41 | dir -name
42 |
43 | - name: dotnet nuget push to GitHub
44 | uses: tanaka-takayoshi/nuget-publish-to-github-packages-action@v2.1
45 | with:
46 | nupkg-path: 'dest\*.nupkg'
47 | repo-owner: 'EasyAbp'
48 | gh-user: 'EasyAbp'
49 | token: ${{ secrets.GITHUB_TOKEN }}
50 |
51 | - name: dotnet nuget push to NuGet
52 | run: dotnet nuget push dest\*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate
53 |
54 | - name: determine if the tag exists
55 | uses: mukunku/tag-exists-action@v1.0.0
56 | id: checkTag
57 | with:
58 | tag: ${{ steps.getVersion.outputs.first_match }}
59 | env:
60 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61 |
62 | - name: add git tag
63 | if: ${{ steps.checkTag.outputs.exists == 'false' }}
64 | uses: tvdias/github-tagger@v0.0.1
65 | with:
66 | repo-token: ${{ secrets.GITHUB_TOKEN }}
67 | tag: ${{ steps.getVersion.outputs.first_match }}
68 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 | *.VC.VC.opendb
85 |
86 | # Visual Studio profiler
87 | *.psess
88 | *.vsp
89 | *.vspx
90 | *.sap
91 |
92 | # TFS 2012 Local Workspace
93 | $tf/
94 |
95 | # Guidance Automation Toolkit
96 | *.gpState
97 |
98 | # ReSharper is a .NET coding add-in
99 | _ReSharper*/
100 | *.[Rr]e[Ss]harper
101 | *.DotSettings.user
102 |
103 | # JustCode is a .NET coding add-in
104 | .JustCode
105 |
106 | # TeamCity is a build add-in
107 | _TeamCity*
108 |
109 | # DotCover is a Code Coverage Tool
110 | *.dotCover
111 |
112 | # NCrunch
113 | _NCrunch_*
114 | .*crunch*.local.xml
115 | nCrunchTemp_*
116 |
117 | # MightyMoose
118 | *.mm.*
119 | AutoTest.Net/
120 |
121 | # Web workbench (sass)
122 | .sass-cache/
123 |
124 | # Installshield output folder
125 | [Ee]xpress/
126 |
127 | # DocProject is a documentation generator add-in
128 | DocProject/buildhelp/
129 | DocProject/Help/*.HxT
130 | DocProject/Help/*.HxC
131 | DocProject/Help/*.hhc
132 | DocProject/Help/*.hhk
133 | DocProject/Help/*.hhp
134 | DocProject/Help/Html2
135 | DocProject/Help/html
136 |
137 | # Click-Once directory
138 | publish/
139 |
140 | # Publish Web Output
141 | *.[Pp]ublish.xml
142 | *.azurePubxml
143 | # TODO: Comment the next line if you want to checkin your web deploy settings
144 | # but database connection strings (with potential passwords) will be unencrypted
145 | *.pubxml
146 | *.publishproj
147 |
148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
149 | # checkin your Azure Web App publish settings, but sensitive information contained
150 | # in these scripts will be unencrypted
151 | PublishScripts/
152 |
153 | # NuGet Packages
154 | *.nupkg
155 | # The packages folder can be ignored because of Package Restore
156 | **/packages/*
157 | # except build/, which is used as an MSBuild target.
158 | !**/packages/build/
159 | # Uncomment if necessary however generally it will be regenerated when needed
160 | #!**/packages/repositories.config
161 | # NuGet v3's project.json files produces more ignoreable files
162 | *.nuget.props
163 | *.nuget.targets
164 |
165 | # Microsoft Azure Build Output
166 | csx/
167 | *.build.csdef
168 |
169 | # Microsoft Azure Emulator
170 | ecf/
171 | rcf/
172 |
173 | # Windows Store app package directories and files
174 | AppPackages/
175 | BundleArtifacts/
176 | Package.StoreAssociation.xml
177 | _pkginfo.txt
178 |
179 | # Visual Studio cache files
180 | # files ending in .cache can be ignored
181 | *.[Cc]ache
182 | # but keep track of directories ending in .cache
183 | !*.[Cc]ache/
184 |
185 | # Others
186 | ClientBin/
187 | ~$*
188 | *~
189 | *.dbmdl
190 | *.dbproj.schemaview
191 | *.pfx
192 | *.publishsettings
193 | node_modules/
194 | orleans.codegen.cs
195 |
196 | # Since there are multiple workflows, uncomment next line to ignore bower_components
197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
198 | #bower_components/
199 |
200 | # RIA/Silverlight projects
201 | Generated_Code/
202 |
203 | # Backup & report files from converting an old project file
204 | # to a newer Visual Studio version. Backup files are not needed,
205 | # because we have git ;-)
206 | _UpgradeReport_Files/
207 | Backup*/
208 | UpgradeLog*.XML
209 | UpgradeLog*.htm
210 |
211 | # SQL Server files
212 | *.mdf
213 | *.ldf
214 |
215 | # Business Intelligence projects
216 | *.rdl.data
217 | *.bim.layout
218 | *.bim_*.settings
219 |
220 | # Microsoft Fakes
221 | FakesAssemblies/
222 |
223 | # GhostDoc plugin setting file
224 | *.GhostDoc.xml
225 |
226 | # Node.js Tools for Visual Studio
227 | .ntvs_analysis.dat
228 |
229 | # Visual Studio 6 build log
230 | *.plg
231 |
232 | # Visual Studio 6 workspace options file
233 | *.opt
234 |
235 | # Visual Studio LightSwitch build output
236 | **/*.HTMLClient/GeneratedArtifacts
237 | **/*.DesktopClient/GeneratedArtifacts
238 | **/*.DesktopClient/ModelManifest.xml
239 | **/*.Server/GeneratedArtifacts
240 | **/*.Server/ModelManifest.xml
241 | _Pvt_Extensions
242 |
243 | # Paket dependency manager
244 | .paket/paket.exe
245 | paket-files/
246 |
247 | # FAKE - F# Make
248 | .fake/
249 |
250 | # JetBrains Rider
251 | .idea/
252 | *.sln.iml
253 |
254 | # RelatedEntityDtoLoader
255 | host/AwesomeAbp.RelatedEntityDtoLoader.IdentityServer/Logs/logs.txt
256 | host/AwesomeAbp.RelatedEntityDtoLoader.HttpApi.Host/Logs/logs.txt
257 | host/AwesomeAbp.RelatedEntityDtoLoader.Web.Host/Logs/logs.txt
258 | host/AwesomeAbp.RelatedEntityDtoLoader.Web.Unified/Logs/logs.txt
259 | obj
260 |
--------------------------------------------------------------------------------
/EasyAbp.Abp.RelatedDtoLoader.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29001.49
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyAbp.Abp.RelatedDtoLoader.Abstractions", "src\EasyAbp.Abp.RelatedDtoLoader.Abstractions\EasyAbp.Abp.RelatedDtoLoader.Abstractions.csproj", "{BD65D04F-08D5-40C1-8C24-77CA0BACB877}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyAbp.Abp.RelatedDtoLoader", "src\EasyAbp.Abp.RelatedDtoLoader\EasyAbp.Abp.RelatedDtoLoader.csproj", "{78040F9E-3501-4A40-82DF-00A597710F35}"
9 | EndProject
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{649A3FFA-182F-4E56-9717-E6A9A2BEC545}"
11 | EndProject
12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{34FD671D-3B3F-498A-ACF5-A73E03111E4E}"
13 | EndProject
14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyAbp.Abp.RelatedDtoLoader.UnitTests", "test\EasyAbp.Abp.RelatedDtoLoader.UnitTests\EasyAbp.Abp.RelatedDtoLoader.UnitTests.csproj", "{71FAA9F6-62CA-4DFC-BBD2-135C7B1412A0}"
15 | EndProject
16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyAbp.Abp.RelatedDtoLoader.TestBase", "test\EasyAbp.Abp.RelatedDtoLoader.TestBase\EasyAbp.Abp.RelatedDtoLoader.TestBase.csproj", "{FADAFEA9-E6FD-4519-9419-8169E8387774}"
17 | EndProject
18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyAbp.Abp.RelatedDtoLoader.IntegratedTests", "test\EasyAbp.Abp.RelatedDtoLoader.IntegratedTests\EasyAbp.Abp.RelatedDtoLoader.IntegratedTests.csproj", "{0A0DC5ED-BF43-4219-A141-B9ED118A3C86}"
19 | EndProject
20 | Global
21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
22 | Debug|Any CPU = Debug|Any CPU
23 | Release|Any CPU = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {BD65D04F-08D5-40C1-8C24-77CA0BACB877}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {BD65D04F-08D5-40C1-8C24-77CA0BACB877}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {BD65D04F-08D5-40C1-8C24-77CA0BACB877}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {BD65D04F-08D5-40C1-8C24-77CA0BACB877}.Release|Any CPU.Build.0 = Release|Any CPU
30 | {78040F9E-3501-4A40-82DF-00A597710F35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {78040F9E-3501-4A40-82DF-00A597710F35}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 | {78040F9E-3501-4A40-82DF-00A597710F35}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {78040F9E-3501-4A40-82DF-00A597710F35}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {71FAA9F6-62CA-4DFC-BBD2-135C7B1412A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {71FAA9F6-62CA-4DFC-BBD2-135C7B1412A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {71FAA9F6-62CA-4DFC-BBD2-135C7B1412A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 | {71FAA9F6-62CA-4DFC-BBD2-135C7B1412A0}.Release|Any CPU.Build.0 = Release|Any CPU
38 | {FADAFEA9-E6FD-4519-9419-8169E8387774}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 | {FADAFEA9-E6FD-4519-9419-8169E8387774}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 | {FADAFEA9-E6FD-4519-9419-8169E8387774}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {FADAFEA9-E6FD-4519-9419-8169E8387774}.Release|Any CPU.Build.0 = Release|Any CPU
42 | {0A0DC5ED-BF43-4219-A141-B9ED118A3C86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43 | {0A0DC5ED-BF43-4219-A141-B9ED118A3C86}.Debug|Any CPU.Build.0 = Debug|Any CPU
44 | {0A0DC5ED-BF43-4219-A141-B9ED118A3C86}.Release|Any CPU.ActiveCfg = Release|Any CPU
45 | {0A0DC5ED-BF43-4219-A141-B9ED118A3C86}.Release|Any CPU.Build.0 = Release|Any CPU
46 | EndGlobalSection
47 | GlobalSection(SolutionProperties) = preSolution
48 | HideSolutionNode = FALSE
49 | EndGlobalSection
50 | GlobalSection(NestedProjects) = preSolution
51 | {BD65D04F-08D5-40C1-8C24-77CA0BACB877} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545}
52 | {78040F9E-3501-4A40-82DF-00A597710F35} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545}
53 | {71FAA9F6-62CA-4DFC-BBD2-135C7B1412A0} = {34FD671D-3B3F-498A-ACF5-A73E03111E4E}
54 | {FADAFEA9-E6FD-4519-9419-8169E8387774} = {34FD671D-3B3F-498A-ACF5-A73E03111E4E}
55 | {0A0DC5ED-BF43-4219-A141-B9ED118A3C86} = {34FD671D-3B3F-498A-ACF5-A73E03111E4E}
56 | EndGlobalSection
57 | GlobalSection(ExtensibilityGlobals) = postSolution
58 | SolutionGuid = {4324B3B4-B60B-4E3C-91D8-59576B4E26DD}
59 | EndGlobalSection
60 | EndGlobal
61 |
--------------------------------------------------------------------------------
/EasyAbp.Abp.RelatedDtoLoader.sln.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
3 | WARNING
4 | WARNING
5 | WARNING
6 | WARNING
7 | WARNING
8 | WARNING
9 | WARNING
10 | WARNING
11 | Required
12 | Required
13 | Required
14 | Required
15 | False
16 | True
17 | False
18 | False
19 | True
20 | False
21 | False
22 | SQL
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 EasyAbp Team
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | /docs/README.md
--------------------------------------------------------------------------------
/common.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | latest
4 | 0.4.0
5 | $(NoWarn);CS1591
6 | true
7 | EasyAbp Team
8 | An Abp module to help you automatically load related DTO (like ProductDto in OrderDto) under DDD.
9 | https://github.com/EasyAbp/Abp.RelatedDtoLoader
10 | https://github.com/EasyAbp/Abp.RelatedDtoLoader
11 | abp module easyabp dto related loader ddd
12 | EasyAbp
13 | MIT
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | all
24 | runtime; build; native; contentfiles; analyzers
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/docs/CustomDtoSource.md:
--------------------------------------------------------------------------------
1 | # Example 1
2 |
3 | Get DTOs from application service
4 | ```csharp
5 | public class MyProjectRelatedDtoLoaderProfile : RelatedDtoLoaderProfile
6 | {
7 | public MyProjectRelatedDtoLoaderProfile(IServiceProvider serviceProvider) : base(serviceProvider)
8 | {
9 | CreateRule(async ids =>
10 | {
11 | var dtos = new List();
12 |
13 | using (var scope = serviceProvider.CreateScope())
14 | {
15 | var productAppService = scope.ServiceProvider.GetService();
16 |
17 | foreach (var id in ids)
18 | {
19 | dtos.Add(await productAppService.GetAsync(id));
20 | }
21 | }
22 |
23 | return dtos;
24 | });
25 | }
26 | }
27 | ```
28 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | # Abp.RelatedDtoLoader
2 |
3 | [](https://www.nuget.org/packages/EasyAbp.Abp.RelatedDtoLoader)
4 | [](https://www.nuget.org/packages/EasyAbp.Abp.RelatedDtoLoader)
5 |
6 | An Abp module that help you automatically load related DTO (like ProductDto in OrderDto) under DDD.
7 |
8 | ## Installation
9 |
10 | 1. Install the following NuGet packages. ([see how](https://github.com/EasyAbp/EasyAbpGuide/blob/master/docs/How-To.md#add-nuget-packages))
11 |
12 | * EasyAbp.Abp.RelatedDtoLoader
13 | * EasyAbp.Abp.RelatedDtoLoader.Abstractions
14 |
15 | 1. Add `DependsOn(typeof(AbpRelatedDtoLoaderModule))` attribute to configure the module dependencies. ([see how](https://github.com/EasyAbp/EasyAbpGuide/blob/master/docs/How-To.md#add-module-dependencies))
16 |
17 | ## Usage
18 |
19 | 1. Make your `Order` **entity** (or aggregate root) like this.
20 | ```csharp
21 | public class Order : AggregateRoot
22 | {
23 | public virtual Guid ProductId { get; protected set; }
24 |
25 | // do not add navigation properties to other aggregate roots!
26 | // public virtual Product Product { get; set; }
27 |
28 | protected Order() { }
29 |
30 | public Order(Guid id, Guid productId) : base(id)
31 | {
32 | ProductId = productId;
33 | }
34 | }
35 | ```
36 |
37 | 1. Add `RelatedDto` attribute in `OrderDto`.
38 | ```csharp
39 | public class OrderDto : EntityDto
40 | {
41 | public Guid ProductId { get; set; }
42 |
43 | //Automatic matching rules $"{nameof(Product)}Id"
44 | [RelatedDto]
45 | public ProductDto Product { get; set; }
46 |
47 | //Manually matching the ProductId
48 | [RelatedDto(nameof(ProductId))]
49 | public ProductDto ProductInfo { get; set; }
50 | }
51 | ```
52 |
53 | 1. Create `MyProjectRelatedDtoLoaderProfile` and add a rule.
54 | ```csharp
55 | public class MyProjectRelatedDtoLoaderProfile : RelatedDtoLoaderProfile
56 | {
57 | public MyRelatedDtoLoaderProfile()
58 | {
59 | // the following example gets entities from a repository and maps them to DTOs.
60 | UseRepositoryLoader();
61 |
62 | // or load it by a customized function.
63 | UseLoader(GetOrderDtosAsync);
64 |
65 | // a target type need to be enabled to load its related Dtos properties.
66 | // LoadForDto();
67 | }
68 | }
69 | ```
70 |
71 | 1. Configure the RelatedDtoLoader to use the profile.
72 | ```csharp
73 | public override void ConfigureServices(ServiceConfigurationContext context)
74 | {
75 | // ...
76 |
77 | Configure(options =>
78 | {
79 | // add the Profile
80 | options.AddProfile();
81 | });
82 |
83 | // ...
84 | }
85 | ```
86 |
87 | 1. Enable the target type to load its related Dto properties.
88 |
89 | either in the Profile
90 | ```csharp
91 | public class MyProjectRelatedDtoLoaderProfile : RelatedDtoLoaderProfile
92 | {
93 | public MyRelatedDtoLoaderProfile()
94 | {
95 | // ...
96 |
97 | // a target type need to be enabled to load its related Dtos properties.
98 | LoadForDto();
99 | }
100 | }
101 | ```
102 |
103 | or via `RegisterTargetDtosInModule method` of RelatedDtoLoaderOptions
104 | ```csharp
105 | public override void ConfigureServices(ServiceConfigurationContext context)
106 | {
107 | // ...
108 |
109 | Configure(options =>
110 | {
111 | // adding module will auto register all the target dto types which contain any property with RelatedDto attribute.
112 | options.LoadForDtosInModule();
113 | });
114 |
115 | // ...
116 | }
117 | ```
118 |
119 | 1. Try to get OrderDto with ProductDto.
120 | ```csharp
121 | public class OrderAppService : ApplicationService, IOrderAppService
122 | {
123 | private readonly IRelatedDtoLoader _relatedDtoLoader;
124 | private readonly IRepository _orderRepository;
125 |
126 | public OrderAppService(IRelatedDtoLoader relatedDtoLoader, IRepository orderRepository)
127 | {
128 | _relatedDtoLoader = relatedDtoLoader;
129 | _orderRepository = orderRepository;
130 | }
131 |
132 | public async Task GetAsync(Guid id)
133 | {
134 | var order = await _orderRepository.GetAsync(id);
135 |
136 | var orderDto = ObjectMapper.Map(order);
137 |
138 | //LoadAsync
139 | return await _relatedDtoLoader.LoadAsync(orderDto); // orderDto.Product should have been loaded.
140 | }
141 |
142 | protected override async Task> MapToGetListOutputDtosAsync(List entities)
143 | {
144 | var orderDtos = await base.MapToGetListOutputDtosAsync(entities);
145 |
146 | //LoadListAsync
147 | return (await _relatedDtoLoader.LoadListAsync(orderDtos)).ToList(); // OrderDto.Product should have been loaded.
148 | }
149 | }
150 | ```
151 |
152 | See more: [Custom DTO source examples](/docs/CustomDtoSource.md).
153 |
154 | ## Roadmap
155 |
156 | - [x] Custom DTO source
157 | - [x] Support one-to-many relation
158 | - [x] Support non Guid keys
159 | - [x] Support multi module development
160 | - [ ] Support nested DTOs loading
161 | - [ ] Get duplicate DTO from memory
162 | - [ ] DTO cache
163 | - [ ] An option to enable loading deleted DTO
164 | - [x] Unit test
165 |
166 | Thanks [@wakuflair](https://github.com/wakuflair) and [@itryan](https://github.com/itryan) for their contribution in the first version.
167 |
--------------------------------------------------------------------------------
/nupkg/common.ps1:
--------------------------------------------------------------------------------
1 | # Paths
2 | $packFolder = (Get-Item -Path "./" -Verbose).FullName
3 | $rootFolder = Join-Path $packFolder "../"
4 |
5 | # List of projects
6 | $projects = (
7 |
8 | "src/EasyAbp.Abp.RelatedDtoLoader",
9 | "src/EasyAbp.Abp.RelatedDtoLoader.Abstractions"
10 | )
--------------------------------------------------------------------------------
/nupkg/pack.ps1:
--------------------------------------------------------------------------------
1 | . ".\common.ps1"
2 |
3 | # Rebuild solution
4 | Set-Location $rootFolder
5 | & dotnet restore
6 |
7 | # Create all packages
8 | foreach($project in $projects) {
9 |
10 | $projectFolder = Join-Path $rootFolder $project
11 |
12 | # Create nuget pack
13 | Set-Location $projectFolder
14 | Remove-Item -Recurse (Join-Path $projectFolder "bin/Release")
15 | & dotnet build -c Release
16 | & dotnet pack -c Release
17 |
18 | if (-Not $?) {
19 | Write-Host ("Packaging failed for the project: " + $projectFolder)
20 | exit $LASTEXITCODE
21 | }
22 |
23 | # Copy nuget package
24 | $projectName = $project.Substring($project.LastIndexOf("/") + 1)
25 | $projectPackPath = Join-Path $projectFolder ("/bin/Release/" + $projectName + ".*.nupkg")
26 | Move-Item $projectPackPath $packFolder
27 |
28 | }
29 |
30 | # Go back to the pack folder
31 | Set-Location $packFolder
--------------------------------------------------------------------------------
/nupkg/push_packages.ps1:
--------------------------------------------------------------------------------
1 | . ".\common.ps1"
2 |
3 | # Get the version
4 | [xml]$commonPropsXml = Get-Content (Join-Path $rootFolder "common.props")
5 | $version = $commonPropsXml.Project.PropertyGroup.Version
6 |
7 | # Publish all packages
8 | foreach($project in $projects) {
9 | $projectName = $project.Substring($project.LastIndexOf("/") + 1)
10 | & dotnet nuget push ($projectName + "." + $version + ".nupkg") -s https://api.nuget.org/v3/index.json
11 | }
12 |
13 | # Go back to the pack folder
14 | Set-Location $packFolder
15 |
--------------------------------------------------------------------------------
/src/EasyAbp.Abp.RelatedDtoLoader.Abstractions/EasyAbp.Abp.RelatedDtoLoader.Abstractions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | netstandard2.0
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/EasyAbp.Abp.RelatedDtoLoader.Abstractions/EasyAbp/Abp/RelatedDtoLoader/RelatedDtoAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EasyAbp.Abp.RelatedDtoLoader
4 | {
5 | [AttributeUsage(AttributeTargets.Property)]
6 | public class RelatedDtoAttribute : Attribute
7 | {
8 | public readonly string IdPropertyName;
9 |
10 | public RelatedDtoAttribute()
11 | {
12 | }
13 |
14 | public RelatedDtoAttribute(string idPropertyName)
15 | {
16 | IdPropertyName = idPropertyName;
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/src/EasyAbp.Abp.RelatedDtoLoader.Abstractions/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/EasyAbp.Abp.RelatedDtoLoader.Abstractions/FodyWeavers.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.
16 |
17 |
18 |
19 |
20 | A comma-separated list of error codes that can be safely ignored in assembly verification.
21 |
22 |
23 |
24 |
25 | 'false' to turn off automatic generation of the XML Schema file.
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/EasyAbp.Abp.RelatedDtoLoader/EasyAbp.Abp.RelatedDtoLoader.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | netstandard2.0
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/EasyAbp.Abp.RelatedDtoLoader/EasyAbp/Abp/RelatedDtoLoader/AbpRelatedDtoLoaderModule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EasyAbp.Abp.RelatedDtoLoader.Configurations;
3 | using Microsoft.Extensions.DependencyInjection;
4 | using Microsoft.Extensions.Options;
5 | using Volo.Abp;
6 | using Volo.Abp.Modularity;
7 |
8 | namespace EasyAbp.Abp.RelatedDtoLoader
9 | {
10 | public class AbpRelatedDtoLoaderModule : AbpModule
11 | {
12 | public override void ConfigureServices(ServiceConfigurationContext context)
13 | {
14 | context.Services.AddSingleton(CreateDtoLoaderConfiguration);
15 | }
16 |
17 | public override void OnPreApplicationInitialization(ApplicationInitializationContext context)
18 | {
19 | }
20 |
21 | private DtoLoaderConfiguration CreateDtoLoaderConfiguration(IServiceProvider serviceProvider)
22 | {
23 | var options = serviceProvider.GetRequiredService>().Value;
24 |
25 | var configuration = new DtoLoaderConfiguration(configurationExpression =>
26 | {
27 | var context = new RelatedDtoLoaderConfigurationContext(configurationExpression, serviceProvider);
28 |
29 | foreach (var configurator in options.Configurators)
30 | {
31 | configurator(context);
32 | }
33 | });
34 |
35 | return configuration;
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/src/EasyAbp.Abp.RelatedDtoLoader/EasyAbp/Abp/RelatedDtoLoader/Configurations/DtoLoaderConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Concurrent;
3 | using System.Collections.Generic;
4 | using EasyAbp.Abp.RelatedDtoLoader.DtoLoadRule;
5 | using EasyAbp.Abp.RelatedDtoLoader.RelatedDtoLoaderProfile;
6 | using EasyAbp.Abp.RelatedDtoLoader.RelatedDtoProperty;
7 |
8 | namespace EasyAbp.Abp.RelatedDtoLoader.Configurations
9 | {
10 | public class DtoLoaderConfiguration : IDtoLoaderConfigurationProvider
11 | {
12 | private readonly Dictionary _dtoLoaderRules = new Dictionary();
13 |
14 | private readonly IEnumerable _profiles;
15 |
16 | private readonly ConcurrentDictionary _targetDtoPropertyCollections =
17 | new ConcurrentDictionary();
18 |
19 | public DtoLoaderConfiguration(DtoLoaderConfigurationExpression configurationExpression)
20 | {
21 | _profiles = configurationExpression.Profiles;
22 |
23 | FinalizeProfiles();
24 | }
25 |
26 | public DtoLoaderConfiguration(Action configure)
27 | : this(Build(configure))
28 | {
29 | }
30 |
31 | public RelatedDtoPropertyCollection GetRelatedDtoProperties(Type targetDtoType)
32 | {
33 | return _targetDtoPropertyCollections.ContainsKey(targetDtoType)
34 | ? _targetDtoPropertyCollections[targetDtoType]
35 | : null;
36 | }
37 |
38 | public IDtoLoadRule GetLoadRule(Type type)
39 | {
40 | return _dtoLoaderRules.ContainsKey(type) ? _dtoLoaderRules[type] : null;
41 | }
42 |
43 | private static DtoLoaderConfigurationExpression Build(Action configure)
44 | {
45 | var expr = new DtoLoaderConfigurationExpression();
46 | configure(expr);
47 | return expr;
48 | }
49 |
50 | private void FinalizeProfiles()
51 | {
52 | foreach (var profile in _profiles)
53 | {
54 | foreach (var dtoLoaderRule in profile.DtoLoaderRules)
55 | {
56 | _dtoLoaderRules[dtoLoaderRule.Key] = dtoLoaderRule.Value;
57 | }
58 |
59 | foreach (var relatedDtoProps in profile.TargetDtoPropertyCollections)
60 | {
61 | _targetDtoPropertyCollections[relatedDtoProps.Key] = relatedDtoProps.Value;
62 | }
63 | }
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/src/EasyAbp.Abp.RelatedDtoLoader/EasyAbp/Abp/RelatedDtoLoader/Configurations/DtoLoaderConfigurationExpression.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using EasyAbp.Abp.RelatedDtoLoader.RelatedDtoLoaderProfile;
6 | using Volo.Abp.Application.Dtos;
7 |
8 | namespace EasyAbp.Abp.RelatedDtoLoader.Configurations
9 | {
10 | public class DtoLoaderConfigurationExpression
11 | {
12 | private static readonly Type EntityDtoType = typeof(IEntityDto);
13 | private static readonly Type ProfileType = typeof(IRelatedDtoLoaderProfile);
14 |
15 | private readonly IList _profiles = new List();
16 |
17 | public bool AutoUseRepositoryLoader { get; set; }
18 |
19 | public IEnumerable Profiles => _profiles;
20 |
21 | public void AddProfile(IRelatedDtoLoaderProfile profile)
22 | {
23 | _profiles.Add(profile);
24 | }
25 |
26 | public void AddAssemblies(RelatedDtoLoaderAssemblyOptions options, params Assembly[] assembliesToScan)
27 | {
28 | AddAssembliesCore(options, assembliesToScan);
29 | }
30 |
31 | private void AddAssembliesCore(RelatedDtoLoaderAssemblyOptions options, IEnumerable assembliesToScan)
32 | {
33 | options = options ?? new RelatedDtoLoaderAssemblyOptions();
34 |
35 | var allTypes = assembliesToScan.Where(a => !a.IsDynamic && a != typeof(NamedProfile).Assembly)
36 | .SelectMany(a => a.DefinedTypes)
37 | .Where(x => !x.IsAbstract)
38 | .ToArray();
39 |
40 | var profileTypes = allTypes.Where(x => ProfileType.IsAssignableFrom(x)).ToArray();
41 |
42 | foreach (var type in profileTypes)
43 | {
44 | var profile = (IRelatedDtoLoaderProfile) Activator.CreateInstance(type);
45 | AddProfile(profile);
46 | }
47 |
48 | var dynamicLoaderProfile = new NamedProfile();
49 |
50 | if (options.AutoEnableTargetDtoTypes)
51 | {
52 | var dtoTypes = allTypes.Where(x => EntityDtoType.IsAssignableFrom(x)).ToArray();
53 |
54 | foreach (var type in dtoTypes)
55 | {
56 | if (EntityDtoType.IsAssignableFrom(type))
57 | {
58 | dynamicLoaderProfile.LoadForDto(type);
59 | }
60 | }
61 | }
62 |
63 | AddProfile(dynamicLoaderProfile);
64 | }
65 |
66 | private class NamedProfile : RelatedDtoLoaderProfile.RelatedDtoLoaderProfile
67 | {
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/src/EasyAbp.Abp.RelatedDtoLoader/EasyAbp/Abp/RelatedDtoLoader/Configurations/IDtoLoaderConfigurationProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EasyAbp.Abp.RelatedDtoLoader.DtoLoadRule;
3 | using EasyAbp.Abp.RelatedDtoLoader.RelatedDtoProperty;
4 |
5 | namespace EasyAbp.Abp.RelatedDtoLoader.Configurations
6 | {
7 | public interface IDtoLoaderConfigurationProvider
8 | {
9 | RelatedDtoPropertyCollection GetRelatedDtoProperties(Type targetDtoType);
10 |
11 | IDtoLoadRule GetLoadRule(Type type);
12 | }
13 | }
--------------------------------------------------------------------------------
/src/EasyAbp.Abp.RelatedDtoLoader/EasyAbp/Abp/RelatedDtoLoader/Configurations/IRelatedDtoLoaderConfigurationContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EasyAbp.Abp.RelatedDtoLoader.Configurations
4 | {
5 | public interface IRelatedDtoLoaderConfigurationContext
6 | {
7 | DtoLoaderConfigurationExpression ConfigurationExpression { get; }
8 | IServiceProvider ServiceProvider { get; }
9 | }
10 | }
--------------------------------------------------------------------------------
/src/EasyAbp.Abp.RelatedDtoLoader/EasyAbp/Abp/RelatedDtoLoader/Configurations/RelatedDtoLoaderAssemblyOptions.cs:
--------------------------------------------------------------------------------
1 | namespace EasyAbp.Abp.RelatedDtoLoader.Configurations
2 | {
3 | public class RelatedDtoLoaderAssemblyOptions
4 | {
5 | public bool AutoEnableTargetDtoTypes { get; set; } = true;
6 | }
7 | }
--------------------------------------------------------------------------------
/src/EasyAbp.Abp.RelatedDtoLoader/EasyAbp/Abp/RelatedDtoLoader/Configurations/RelatedDtoLoaderConfigurationContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EasyAbp.Abp.RelatedDtoLoader.Configurations
4 | {
5 | public class RelatedDtoLoaderConfigurationContext : IRelatedDtoLoaderConfigurationContext
6 | {
7 | public RelatedDtoLoaderConfigurationContext(
8 | DtoLoaderConfigurationExpression configurationExpression,
9 | IServiceProvider serviceProvider)
10 | {
11 | ConfigurationExpression = configurationExpression;
12 | ServiceProvider = serviceProvider;
13 | }
14 |
15 | public DtoLoaderConfigurationExpression ConfigurationExpression { get; }
16 |
17 | public IServiceProvider ServiceProvider { get; }
18 | }
19 | }
--------------------------------------------------------------------------------
/src/EasyAbp.Abp.RelatedDtoLoader/EasyAbp/Abp/RelatedDtoLoader/Configurations/RelatedDtoLoaderOptions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using EasyAbp.Abp.RelatedDtoLoader.RelatedDtoLoaderProfile;
4 |
5 | namespace EasyAbp.Abp.RelatedDtoLoader.Configurations
6 | {
7 | public class RelatedDtoLoaderOptions
8 | {
9 | public RelatedDtoLoaderOptions()
10 | {
11 | Configurators = new List>();
12 | }
13 |
14 | public List> Configurators { get; }
15 |
16 | public RelatedDtoLoaderAssemblyOptions LoadForDtosInModule()
17 | {
18 | var assembly = typeof(TModule).Assembly;
19 |
20 | Configurators.Add(context => { context.ConfigurationExpression.AddAssemblies(null, assembly); });
21 |
22 | return null;
23 | }
24 |
25 | public void AddProfile()
26 | where TProfile : IRelatedDtoLoaderProfile, new()
27 | {
28 | Configurators.Add(context => { context.ConfigurationExpression.AddProfile(new TProfile()); });
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/src/EasyAbp.Abp.RelatedDtoLoader/EasyAbp/Abp/RelatedDtoLoader/DtoLoadRule/DtoLoadRule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Volo.Abp.Application.Dtos;
6 |
7 | namespace EasyAbp.Abp.RelatedDtoLoader.DtoLoadRule
8 | {
9 | public class DtoLoadRule : IDtoLoadRule
10 | where TDto : class, IEntityDto
11 | {
12 | public DtoLoadRule(Func, Task>> rule)
13 | : this()
14 | {
15 | Rule = rule;
16 | }
17 |
18 | protected DtoLoadRule()
19 | {
20 | }
21 |
22 | protected Func, Task>> Rule { get; set; }
23 |
24 | public async Task> LoadAsObjectAsync(IServiceProvider serviceProvider,
25 | IEnumerable